Ultimate Flex DataGrid - Customizing Print, Print Preview and PDF Generation

clock April 12, 2011 02:52 by author Flexicious

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.


Flexicious Ultimate and Classic Flex DataGrid 2.2 - Multi Column Sort - Column Groups - Spinner - Compact Preferences

clock April 7, 2011 09:46 by author Flexicious

So last week, we announced some cool features that were pushed into 2.1. All of the features that went into 2.1 were specific to Ultimate. However, in the upcoming release (2.2), we will be adding a feature that has been high on our list for Classic - Compact Preferences. Currently, when we persist preferences, we build a massive XML string. In some grids, this string could grow up 20-30K characters. WE have implemented a much more compact mechanism for persisting and parsing these strings, and now we are able to persist most grids in under 1 K characters, and in some cases as little as 2-300 characters. There is a property, useCompactPreferences, which has been introduced which will default to false (in which case it will still use the older verbose persistence) but you can set this to true. We defaulted it to false so our Customers who upgrade do not run into issues with currently persisted strings.We have also done some code refactoring to ensure code reuse and the like, but nothing that affects public APIS.

Also - We added support for Persisting Column Groups of the Advanced datagrid in user preferences. This was not being persisted before.

That said, EXCITING new features in Ultimate:

1) Multi Column Sort : We've learnt from the experience of the DataVisualization team at Adobe, with the awkward multi column sort in the Advanced DataGrid from the SDK. It's almost painful to watch non techies try to use it. So we've tried to come up with a slightly better, more intuitive UI, hope it's clearer.

2) Column Groups : This is big, we're gonna create some really good looking Grids with grouped columns. Our Financial Clients are going to love this one. Want to see columns broken down by year and then quarter? Column Groups to the rescue...

3) Added Spinner Functionality to Ultimate : The much ignored but really super duper cool spinning ball that will mesmerize your users while the grid loads data!! Well, for those of you who didnt know, Classic has had a "Please Wait" Spinner for a while, but only a few of you adventurous ones have actually found it and used it. So for those who dont know, there are a couple of methods on Classic, showSpinner and hideSpinner, and these will be available on Ultimate in 2.2

4) Enhanced the Spinner so you will be able to define your own spinners: Dont like our spinner? But it spins!! Well, alteast its not the old MSOffice Clippit. But if you like the Clippit, go right ahead and implement it. Just use the spinnerFactory.

5) Added examples to demonstrate customization of the Print/Preview and Reporting functionality.

Oh, and we fixed a couple of bugs, and answered a million questions about Ultimate which we are in the process of compiling for a comprehensive FAQ.

We will be fleshing out more details about the above along with code examples as usual in short order, so keep sending us feedback on what you want to see!!