We had a customer request help in implementing a feature that will probably be handy to a lot of you.

What they basically wanted is that they wanted to customize the print as well as the export output to display information about the filter being currently applied. The idea would be the same if you want to perform any kind of customization to the print/excel output. Basically, we provide certain plugin mechanisms for you to hook into the print/export flow. There are a series of My*.mxml/as files that we provide, that you can customize to suit your requirements. This example demonstrates how you would implement a customization like this.

The solution for this feature is as follows:

1) Implement the logic to convert the filter to a human readable string (Review SampleUIUtils.as, getFilterString)

2) For the print, modify your Print Area of interest (we used the ReportHeader) to call the function above and display the output (See MyReportHeader.mxml, and MyPrintOptions.as)

3) For the export, extend the built in exporters to include the filter information in the export output. (See MyCsvExporter.as, and MyExportOptions.as)

4) In your CustomPagerControl, ensure you are calling PrintController and ExportController like this:

ExportController.instance().export(this.grid,MyExportOptions.create(1)
PrintController.instance().print(this.grid,MyPrintOptions.create())

Please feel free to reach out with any questions!

 

SampleUIUtils.as (3.35 kb)

MyReportHeader.mxml (1.88 kb)

MyPrintOptions.as (1.98 kb)

MyCsvExporter.as (611.00 bytes)

MyExportOptions.as (1.16 kb)

 

===================================================

Update: Another common request is to provide formatting to the XLS output, or to change the extension of the CSVExporter to xls. The ExcelExporter that ships out of the box will create a CSV document, and it will have the csv extension. The approach to both these queries is to use a custom ExcelExporter. Attached below is one such implementation, MyXlsExporter. You can wire this up exactly like above, by inserting it into the MyExportOptions.as and using an instance of MyExportOptions in your CustomPagerControl.

 

MyXlsExporter.as (2.13 kb)

===================================================

Another common issue reported is with Excel not being able to display certain UNICODE characters in the CSV output. The way to handle this is via sending HTML output to excel. Below files demonstrates how to do this.

MyExportOptions.as (1.18 kb)

Utf8ExcelExporter.as (1.09 kb)

 

==================================================

For Ultimate, its a lot easier to override the click event of the excel export button. In Classic (like shown above) you need to create your own pager control. In ultimate, you can simply define a custom toolbarExcelHandlerFunction like below:

public function defaultExcelHandlerFunction():void{
ExtendedExportController.instance().export(this,MyExportOptions.create())
}
Here is a flex project that demonstrates how to do this.

UTF8ExcelExport.zip (6.06 kb)

 

==================================================

Yet Another update - we've added support for highly customizable Excel 2007 OOXML output with Flexicious 3.1 - please review http://blog.flexicious.com/post/Flexicious-30-Release-Grid-Edition.aspx