3 Replies Latest reply: Apr 22, 2013 8:28 PM by Flex harUI RSS

    Flex PrintDataGrid has missing rows

    lmack710

      Hi,

      I've seen this issue posted before. I've tried several of the work arounds and still i get partial or missing rows.I've copy the example from this site:

      my PrintDataGrid Attributes are: sizeToPage="true"  varableRowHeight="true" wordWrap='true'.  even when varableRowHeight and wordWrap are set to false the same problem occurs. here is my code:

       

       

      private function printOrders():void

                  {

                      var printJob:FlexPrintJob = new FlexPrintJob();

                     

                 

                     

                      // Start the print job.

                      if (printJob.start()) {

                          // Create a FormPrintView control

                          // as a child of the application.

                          var thePrintView:AllOrdersPrintView = new AllOrdersPrintView();

                          addElement(thePrintView);

                         

                          // Set the print view properties.

                          thePrintView.width=printJob.pageWidth;

                          thePrintView.height=printJob.pageHeight;

                         

                          // Set the data provider of the FormPrintView

                          // component's DataGrid to be the data provider of

                          // the displayed DataGrid.

                          var arrList:ArrayList = new ArrayList();

                          for each (var x:XML in _orderList){

                              var obj:Object = new Object();

                              obj.idOrder = x.@idOrder;

                              obj.delegate = delegateData(x);

                              obj.grade = x.@grade;

                              obj.purchaser = purchaserData(x);

                              obj.cover = coverTypeData(x);

                              obj.quantity = quantityData(x);

                              obj.date = dateConverter.format(String(XML(x).@orderTime));

                              arrList.addItem(obj);

                          }

                          thePrintView.myDataGrid.dataProvider = arrList;

                         

                          // Create a single-page image.

                          thePrintView.showPage("single");

                         

                          // If the print image's DataGrid can hold all the 

                          // data provider's rows, add the page to the print job.

                          if(!thePrintView.myDataGrid.validNextPage)

                          {

                              printJob.addObject(thePrintView);

                          }

                              // Otherwise, the job requires multiple pages.

                          else

                          {

                              // Create the first page and add it to the print job.

                              thePrintView.showPage("first");

                              printJob.addObject(thePrintView);

                              thePrintView.pageNumber++;

                             

                              // Loop through the following code

                              // until all pages are queued.

                              while(true)

                              {

                                  // Move the next page of data to the top of

                                  // the PrintDataGrid.

                                  thePrintView.myDataGrid.nextPage();

                                 

                                  // Try creating a last page.

                                  thePrintView.showPage("last"); 

                                 

                                  // If the page holds the remaining data, or if

                                  // the last page was completely filled by the last 

                                  // grid data, queue it for printing.

                                  // Test if there is data for another

                                  // PrintDataGrid page.

                                  if(!thePrintView.myDataGrid.validNextPage)

                                  {

                                      // This is the last page;

                                      // queue it and exit the print loop.

                                     

                                      printJob.addObject(thePrintView);

                                      break;

                                  }

                                  else

                                      // This is not the last page. Queue a middle page.

                                  {

                                      thePrintView.showPage("middle");

                                      printJob.addObject(thePrintView);

                                      thePrintView.pageNumber++;

                                  }

                              }

                          }

                          // All pages are queued; remove the FormPrintView

                          // control to free memory.

                          removeElement(thePrintView);

                      }

                      // Send the job to the printer.

                      printJob.send();

                  }

                 

       

       

       

      the grid

       

      <?xml version="1.0"?>

      <!-- printing\myComponents\FormPrintView.mxml -->

      <mx:VBox xmlns:fx="http://ns.adobe.com/mxml/2009"

               xmlns:s="library://ns.adobe.com/flex/spark"

               xmlns:mx="library://ns.adobe.com/flex/mx"

               xmlns:MyComp="myComponents.*"

               backgroundColor="#FFFFFF"

               paddingRight="50" paddingTop="50" paddingBottom="50" paddingLeft="50" xmlns:components="com.treering.components.*">

         

          <fx:Script>

              <![CDATA[

                  import mx.core.*

                     

                      // Declare and initialize the variables used in the component.

                      // The application sets the actual prodTotal value.

                     

             

                  public var pageNumber2:Number = 1;

                  [Bindable]

                  public var pageNumber:Number = 1;

                 

                  // Control the page contents by selectively hiding the header and

                  // footer based on the page type.

                  public function showPage(pageType:String):void {

                 

                      if(pageType == "middle" || pageType == "last") {

                          // The header won't be used again; hide it.

                          header.includeInLayout=false;

                          header.visible = false;

                      }

                     

                      //Update the DataGrid layout to reflect the results.

                      validateNow();

                  }

              ]]>

          </fx:Script>

         

          <!-- The template for the printed page,

          with the contents for all pages. -->

          <mx:VBox width="100%"  horizontalAlign="left">

              <mx:Label text="Page {pageNumber}"/>

          </mx:VBox>

          <components:AllOrdersHeader id="header"/>

         

          <!-- The sizeToPage property is true by default, so the last

          page has only as many grid rows as are needed for the data. -->

          <mx:PrintDataGrid id="myDataGrid" width="100%"   variableRowHeight="true" wordWrap="true"  >

              <!-- Specify the columns to ensure that their order is correct. -->

              <mx:columns>

                  <mx:DataGridColumn dataField="idOrder" width='60' headerText="Order #"  />

                  <mx:DataGridColumn dataField="delegate" headerText="Purchasee" />

                  <mx:DataGridColumn dataField="grade" width="75" headerText="Grade" />

                  <mx:DataGridColumn dataField="purchaser" headerText="Purchaser" />

                  <mx:DataGridColumn dataField="cover" width="40" headerText="Cover"/>

                  <mx:DataGridColumn dataField="quantity" width="60" headerText="Quantity"/>

                  <mx:DataGridColumn dataField="date" headerText="Date"/>

              </mx:columns>

          </mx:PrintDataGrid>

         

         

      </mx:VBox>

       

      thanks

      Larry Ackner