2 Replies Latest reply on Jun 23, 2010 9:01 PM by paulcortez

    PrintDataGrid printing only half the page

    paulcortez Level 1



      I have a problem printing my report with PrintDataGrid. I just copied and paste the sample code form this site but it seems to have a problem. The print out in the paper is only half and jumps to another page. 1 to 6 row is on the first page and the rest is on the next page which supposed to be on a single page. I'm asking for your help finding ways to make it print correctly.


      here i have the code:




                     import mx.core.*
                          // Declare and initialize the variables used in the component.
                          // The application sets the actual prodTotal value.
                     public var pageNumber:Number = 1;
                     public var prodTotal:Number = 0;
                     // Control the page contents by selectively hiding the header and
                     // footer based on the page type.
                     public function showPage(pageType:String):void 
                          if(pageType == "first" || pageType == "middle") 
                               // Hide the footer.
                               footer.visible = false;
                          if(pageType == "middle" || pageType == "last") 
                               // The header won't be used again; hide it.
                               header.visible = false;
                          if(pageType == "last") 
                               // Show the footer.
                               footer.visible = true;
                          //Update the DataGrid layout to reflect the results.
           <!-- The template for the printed page, 
           with the contents for all pages. -->
           <mx:VBox width="90%" horizontalAlign="left">
                <mx:Label text="Page {pageNumber}"/>
           <MyComp:FormPrintHeader id="header"/>
           <mx:PrintDataGrid id="myDataGrid" 
                                 fontFamily="Lucida Console" >
                <!-- Specify the columns to ensure that their order is correct. -->
                     <mx:DataGridColumn headerText="Invoice" dataField="InvoiceNo" width="65"/>
                     <mx:DataGridColumn headerText="Customer" dataField="CustomerName" width="100"/>
                     <mx:DataGridColumn headerText="Model" dataField="ModelNo" width="70"/>
                     <mx:DataGridColumn headerText="Category" dataField="CategoryCode" width="70"/>          
                     <mx:DataGridColumn headerText="Price" dataField="Price" width="80"/>
                     <mx:DataGridColumn headerText="Qty" dataField="Quantity" width="35"/>                    
                     <mx:DataGridColumn headerText="Cash" dataField="Cash" width="80"/>
                     <mx:DataGridColumn headerText="Dollar" dataField="Dollar" width="80"/>
                     <mx:DataGridColumn headerText="Cr Card" dataField="CreditCard" width="80"/>
                     <mx:DataGridColumn headerText="B Share" dataField="Bankshare" width="80"/>
                     <mx:DataGridColumn headerText="W Tax" dataField="WTax" width="80"/>
                     <mx:DataGridColumn headerText="Lay Dep" dataField="LayawayDP" width="80"/>
                     <mx:DataGridColumn headerText="Lay Bal" dataField="LayawayBal" width="80"/>
                     <mx:DataGridColumn headerText="Check" dataField="Check" width="80"/>
                     <mx:DataGridColumn headerText="Misc" dataField="Misc" width="80"/>
                     <mx:DataGridColumn headerText="Remarks" dataField="Remarks"/>
                     <mx:DataGridColumn headerText="Lay Pay" dataField="LayawayPayment" width="80"/>




      and the way i call it from Report.mxml:



      var printJob:FlexPrintJob = new FlexPrintJob();
      if (printJob.start()) {
              var thePrintView:FormSalesTransaction = new FormSalesTransaction();
           thePrintView.prodTotal = prodTotal;
           thePrintView.myDataGrid.dataProvider = salesTransaction;
                printJob.addObject(thePrintView, FlexPrintJobScaleType.MATCH_WIDTH);
                printJob.addObject(thePrintView, FlexPrintJobScaleType.MATCH_WIDTH);
                          printJob.addObject(thePrintView, FlexPrintJobScaleType.MATCH_WIDTH);
                          printJob.addObject(thePrintView, FlexPrintJobScaleType.MATCH_WIDTH);
      printJob.printAsBitmap = false;                    



      Here is the output when I print the report:



      I hope you could have some time to help me.


      Thankz a lot.