<?xml version="1.0" encoding="utf-8"?>
<pager:PagerControl 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:pager="com.flexicious.nestedtreedatagrid.pager.*" >
    <fx:Declarations>
        <!-- Custom pager control to hook in our extended export controller-->
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import com.flexicious.export.ExportOptions;
            import com.flexicious.grids.events.PrintExportOptions;
            import com.flexicious.nestedtreedatagrid.export.ExtendedExportController;
            import com.flexicious.nestedtreedatagrid.print.ExtendedPrintController;
            import com.flexicious.nestedtreedatagrid.print.ExtendedPrintOptionsView;
            import com.flexicious.nestedtreedatagrid.print.PrintFlexDataGrid;
            import com.flexicious.print.PrintOptions;
            
            import mx.core.FlexGlobals;
            
            /**
             * Default handler for the Print Button. Calls
             * var po:PrintOptions=PrintOptions.create();
             * po.printOptionsViewrenderer = new ClassFactory(ExtendedPrintOptionsView);
             * ExtendedPrintController.instance().print(this.grid,po)
             * 
             * We override it here to provide our own headers and footers
             */
            override public function onPrint():void{
                var po:PrintOptions=createPrintOptions();
                po.printToPdf=false;
                ExtendedPrintController.instance().print(this.grid,po)
            }
            /**
             * Default handler for the Print Button. Calls
             * var po:PrintOptions=PrintOptions.create(true);
             * po.printOptionsViewrenderer = new ClassFactory(ExtendedPrintOptionsView);
             * ExtendedPrintController.instance().print(this.grid,po)
             * 
             * We override it here to provide our own headers and footers
             */
            override public function onPdf():void{
                var po:PrintOptions=createPrintOptions();
                po.printToPdf=true;
                ExtendedPrintController.instance().print(this.grid,po)
            }
            
            public function createPrintOptions():PrintOptions{
                var po:PrintOptions=PrintOptions.create(true);
                po.printOptionsViewrenderer = new ClassFactory(ExtendedPrintOptionsView);
                po.reportHeaderRenderer = new ClassFactory(MyReportHeader);
                po.reportFooterRenderer = new ClassFactory(MyReportFooter);
                po.pageHeaderRenderer = new ClassFactory(MyPageHeader);
                po.pageFooterRenderer = new ClassFactory(MyPageFooter);
                po.printPreviewViewrenderer = new ClassFactory(MyPreviewRenderer);
                po.printDataGridRenderer = new ClassFactory(PrintFlexDataGrid);
                po.printExportOption = PrintExportOptions.PRINT_EXPORT_ALL_PAGES;
                //po.showColumnPicker=false;
                //po.preview=false;
                return po;
                
            }
        ]]>
    </fx:Script>
</pager:PagerControl>