One of the lesser visible features of Flexicious is the ability for the product to be used as a customized reporting engine. Since we have invested a significant amount of effort into the preview/pdf engine, this can be used in a variety of use cases, from custom Flex Reports to Printing Invoices, Generating Quotes, pretty much anything where you can imagine a summary section followed by a Flexicious Grid.

 

Among the upcoming lines of effort is the ability to complete decouple the printing/preview piece from the core Grid functionality, so you can use the Print, Preview, and PDF generation independently.

 

The overall flow of the Print functionality is:

1)      You set "enablePrint" to true

2)      The built in pager control shows a Print and PDF icon

3)      When the user clicks any of these, the built in pager control calls the "onPrint" and "onPdf" functions on the built in PagerControl.

4)      These functions basically call the ExtendedPrintController, (the specialized Print Controller for Ultimate), which creates the preview window, instantiates the various parts and creates Print Preview. These options are controlled via the PrintOptions class, which contains information about the renderers to use.

 

Flexicious Print Output Reports look like the following:

 

Report Header (First Page)

Page Header (All Pages)

Grid Body (All Pages)

 

 

 

 

Page Footer (All Pages)

Report Footer (Last Page)

 

Each of the above sections is displayed by its own renderer. There are default renderers provided for them, but you can override them. This is what we are going to do below.

 

1)      First, we define our renderers. In the attachment below, please find MyPageHeader, MyPageFooter, MyReportHeader, and MyReportFooter mxml files. These will represent the various sections defined in the above diagram.

2)      Second, we define our own custom pager control, because this is where we need to hook our renderers. Please find attached, MyCustomPager.mxml. In here, we override the onPrint and onPdf functions, to pass in our PrintOptions object where we instruct the ExtendedPrintController to use speciailized versions of the various Print Renderers.

3)      Third, and the final step, is we wire up our custom pager with the grid using the pagerRenderer property.

As an FYI, if you want to skip the preview and go straight to either print or the pdf, you can simply set printOptions.preview=false in createPrintOptions in MyCustomPager.

Now, when you run the sample application, you will see that clicking on the print produces an preview like below:

 

PrintFiles.zip (3.87 kb)

Edit : Some additional questions:

Is there a way to call the print or pdf functions from outside of the grid, using ActionScript?
-> Yes, all you need to do is to call ExtendedPrintController.instance().print. Review the code inside MyCustomPager.

Is there a way to tell the PrintOptions to select all pages of the grid by default?
-> Yes, in the printOptions, there is a printExportOption property. Set it to PrintExportOptions.PRINT_EXPORT_ALL_PAGES.
po.printExportOption = PrintExportOptions.PRINT_EXPORT_ALL_PAGES;

Is there a way to by-pass all dialogues and simply open the operating system file dialogue or print dialogue?
-> Not in 2.1, but in 2.2, there is a new property called showColumnPicker. This, in combination with the preview boolean flags can skip or show both, the column picker, and the preview window.