3 Replies Latest reply on Mar 2, 2011 5:41 AM by Jerry62712

    How do I get AS to print everything?

    Jerry62712 Level 1

      This is about the second method I'm trying to get a data grid to print.  In this attempt, I'm dynamically creating things and then printing them.  All items are printed, but the format sucks.

       

      1) the user clicks a button below the data grid

      2) in code I create a PrintAdvancedDataGrid, but I don't know how to adjust individual columns

      3) all columns are one width and no wordwrapping happens

                  private function printCaseNotesAS1():void
                  {
                      var flexPrint:FlexPrintJob = new FlexPrintJob();
                      var myGridPrint:PrintAdvancedDataGrid = new PrintAdvancedDataGrid();
                      var numNotes:int = model.dpCASENOTES.length;
                      if (numNotes > 0)
                      {
                          var dataSource:ArrayCollection = new ArrayCollection();
                          for (var i:int = 0; i < numNotes; i++)
                          {
                              var descHolder:Object = new Object();
                              descHolder.Description = (model.dpCASENOTES[i] as CaseNotesVO).shortDescription.toString();
                              descHolder.Description += "\r\n\tprinted from AS1";
                              descHolder.NoteNum = "";
                              descHolder.Notes = "";
                              descHolder.UpdatedBy = "";
                              descHolder.PostedDate = "";
                              dataSource.addItem(descHolder);

                              var dataHolder:Object = new Object();
                              dataHolder.Description = "";
                              dataHolder.NoteNum = (i+1).toString();
                              dataHolder.Notes = (model.dpCASENOTES[i] as CaseNotesVO).notes.toString();
                              dataHolder.UpdatedBy = "";
                              dataHolder.PostedDate = "";
                              dataSource.addItem(dataHolder);

                              var footHolder:Object = new Object();
                              footHolder.Description = "";
                              footHolder.NoteNum = "";
                              footHolder.Notes = "";
                              footHolder.UpdatedBy = (model.dpCASENOTES[i] as CaseNotesVO).updatedBy.toString();
                              footHolder.PostedDate = (model.dpCASENOTES[i] as CaseNotesVO).postTs.toString();
                              dataSource.addItem(footHolder);
                          }

                          if (flexPrint.start())
                          {
                              FlexGlobals.topLevelApplication.addElement(myGridPrint);
                              myGridPrint.dataProvider = dataSource;
                              myGridPrint.width = flexPrint.pageWidth;
                              myGridPrint.height = flexPrint.pageHeight;
                              myGridPrint.variableRowHeight = true;

                              flexPrint.addObject(myGridPrint);
                              while (myGridPrint.validNextPage)
                              {
                                  myGridPrint.nextPage();
                                  flexPrint.addObject(myGridPrint);
                              }

                              flexPrint.send();
                              FlexGlobals.topLevelApplication.removeElement(myGridPrint);
                          }
                      }
                      else
                      {
                          Alert.show("Nothing to print","Warning");
                      }
                  }

       

      How do I address the properties of columns?  The results looks like this

      a) all columns the same width

      b) no wordwrapping for long text

       

      I did a print to file to get it here, but it came out in a non-text format.  Any ideas on how to 1) print it or 2) view it?