2 Replies Latest reply on Feb 24, 2010 10:43 PM by xianyu.ad

    Title of DataGrid is wrong while printing DataGrid

    xianyu.ad

      I try to print out a datagrid like below

      2010-02-25_132206.jpg

      There are 2 problems, one is header title display as dataField value.

      The other is , @Qty (CCC) should be the first column.

      How to solve those problems? Anyone can give me some advice?

      thanks a lot~~!

       

      Here are part of sourcecode,

      <mx:XML id="dgProvider">

             <root>

                 <prod1 Index="112" Qty="223"/>

                 <prod1 Index="14" Qty="67"/>

             <root>

      </mx:XML>

      <mx:AssetsDataGrid id="myDataGrid" dataProvider="{dgProvider.prod1}" width="100%" height="100%">      

                 <mx:columns> 

                    <mx:AdvancedDataGridColumn dataField="@Qty" headerText="CCC"/>

                    <mx:AdvancedDataGridColumn dataField="@Index" headerText="AAA"/>         

                 </mx:columns>

             </mx:AssetsDataGrid>

      public function doPrint():void {
        var myPrintJob = new FlexPrintJob();
        if (myPrintJob.start()) {
         myPrintDataGrid = new PrintAdvancedDataGrid();  //Set the print view properties. 
         myPrintDataGrid.width = myPrintJob.pageWidth; 
         myPrintDataGrid.height = myPrintJob.pageHeight;
        
         // Set the data provider of the FormPrintView component's data grid 
         // to be the data provider of the displayed data grid.
         myPrintDataGrid.dataProvider = myDataGrid.dataProvider; 
         myPrintDataGrid.visible = false; 
         myPrintDataGrid.includeInLayout = false;
         Application.application.addChild(myPrintDataGrid); 
         if(!myPrintDataGrid.validNextPage) {  
          myPrintJob.addObject(myPrintDataGrid); 
         } else {  
          myPrintJob.addObject(myPrintDataGrid);  
          while(true) {   
           // Move the next page of data to the top of the print grid.
           myPrintDataGrid.nextPage();   
           if(!myPrintDataGrid.validNextPage) {    
            // This is the last page; queue it and exit the print loop.    
            myPrintJob.addObject(myPrintDataGrid);    
            break;   
           } else {    
            myPrintJob.addObject(myPrintDataGrid);   
           }  
          } 
         } 
          Application.application.removeChild(myPrintDataGrid); 
          myPrintJob.send();
         }
        }