Domanda

My flex data grid has a XMLListCollection as its data provider.

AlivePDF's Grid expects data grid's data provider to be an array.

Is there a way to PDF this table without going through each and every XML node and populating an array of objects to feed to AlivePDF's Grid?

Are there any other better solutions that I can try out to covert this table to PDF?

Thanks!

È stato utile?

Soluzione

ListCollectionView (XMLListCollection base class) has toArray() method

So, just new Grid(dataProvider.toArray(),...)

Altri suggerimenti

Here is a sample code snippet that may help you : Here dataGrid has 2 columns. And chilledWaterLoopXml is the xml containing the data..

            var gridColumnFirstcol:GridColumn = new GridColumn('Design ΔT','designDelta', 40, Align.LEFT, Align.LEFT);
            var gridColumnSecondcol:GridColumn = new GridColumn('Chilled Water', 'chilledWtrPump', 40, Align.LEFT, Align.LEFT);                 


            var result:ArrayCollection=new ArrayCollection();
            for(var i:int =0;i<chilledWaterLoopXml.children().length();i++)
            {
                var resultant:Object = new Object();
                resultant["designDelta"]=chilledWaterLoopXml.child(i).designDelta;
                resultant["chilledWtrPump"]=chilledWaterLoopXml.child(i).chilledWtrPump;            
                result.addItem(resultant);
            }

            var grid:org.alivepdf.data.Grid = new org.alivepdf.data.Grid( result.toArray() , 100,50, new RGBColor(0xD4CCC5), new RGBColor(0x66C66C),0, new RGBColor(0x000000),1,Joint.ROUND);
            grid.columns = columns;                                                 
            pdf.addGrid(grid);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top