Strategies for printing a page in a CMP?

When the content of the CMP is all that is wanted, do you use print styles to hide and adjust all the many elements of the manager? Or send the user to a page outside of the manager where you can better control the markup? Something else?

Also, when using print styles, is it safe to rely on IDs of the form ext-gennn? They appear to be generated by ExtJS and I have no idea when or whether they might be regenerated.


It is way more effective to write i.e. a PDF export for the table data than creating a nice print CSS for the CMP.

1 Like

In the tbar of the grid you can insert the following:

            xtype: 'button',
            itemId: 'export-items',
            text: '<i class="icon icon-file-pdf-o">',
            handler: this.exportItems

A simple exportItems method can look like this:

    exportItems: function () {
        var dataStore = this.getStore();
        var params = {...dataStore.baseParams};
        var requestParams = Ext.apply(params, {
            action: 'mgr/items/export',
            limit: 0,
            HTTP_MODAUTH: MODx.siteId,
        }); + '?' + Ext.urlEncode(requestParams), '_blank');

Then you have to duplicate the getlist processor and replace/add the outputArray method inside with a PDF generation (in this case with mPDF)

    public function outputArray(array $array, $count = false)
        $output = $this->createOutput($array, $count);


        $mpdf = new Mpdf();
        $mpdf->output('item-export.pdf', Destination::INLINE);

I have used an extjs plugin for this previously.