How to print flexible intrinsically safe datagrid with mx PrintDataGrid? Or is there any other way to achieve this without using mx PrintDataGrid?

This is my first time to ask here since my question is not answering the adobe flex forum. At least, finally, I came to manage it here.

Well, Flex 4.5+, I think everyone is working now, so I asked this question since I have not found work with spark datagrid and mx printdatagrid components yet .

What I'm trying to achieve is to print all the data inside my spark datagrid. Therefore, when I do my research, we use the PrintJob or FlexPrintJob classes. It works fine, but when I need to print multiple pages, since the data on my spark datagrid is quite long, I cannot somehow find a way to do this. Print only up where the height of my spark data source. Therefore, in my research, they somehow managed to use the mx: PrintDataGrid component. But, unfortunately, they did this with mx: DataGrid. Now here is my problem - how to use mx: PrintDataGrid with s: DataGrid .

var printJob:PrintJob = new PrintJob(); if (printJob.start()) { var printGrid:PrintDataGrid = new PrintDataGrid(); printGrid.width = printJob.pageWidth; printGrid.height = printJob.pageHeight; printGrid.columns = mySparkDataGrid.columns; // this line throws an exception printGrid.dataProvider = mySparkDataGrid.dataProvider; printGrid.visible = false; FlexGlobals.topLevelApplication.addElement(printGrid); while (printGrid.validNextPage) { printGrid.nextPage(); printJob.addPage(printGrid); } printJob.send(); parentApplication.removeElement(printGrid); } 

So, please, can someone here help me with this? If it is not possible to convert the columns of the spark datagrid to the columns of mx datagrid, is there a way so that I can print all the data on the spark datagrid with multiple pages?

Thanks so much in advance .

-Ted

+4
source share
1 answer

Try something like this (this works for me)

 for (var i:int = 0; i < mySparkDataGrid.columns.length - 1; i++) { var tmpColumn:DataGridColumn = new DataGridColumn(); tmpColumn.headerText = (mySparkDataGrid.columns.getItemAt(i) as GridColumn).headerText; tmpColumns.push(tmpColumn); } printGrid.columns = tmpColumns; 

Now I need to find a way how to use the DataPender.My dataprovider has more than an object, and I need to analyze it to display the correct data in the grid. I have to do the same for printing. A.

0
source