5.20231.904
5.20231.904

Export RowDetail to PDF

To include row details when exporting grids to PDF, make sure the parameters used in the call to the FlexGridPdfConverter.export method have:

  1. The drawDetailRows option set to true, so the component leaves room for the expanded detail rows, and
  2. The formatItem event has a handler used to render the details into the output document.
import * as core from '@grapecity/wijmo';
import * as grid from '@grapecity/wijmo.grid';
import * as detail from '@grapecity/wijmo.grid.detail';
import * as gridPdf from '@grapecity/wijmo.grid.pdf';

gridPdf.FlexGridPdfConverter.export(theGrid, 'GridDetail.pdf', 
{
    customCellContent: true,
    drawDetailRows: true, // required to make room for the detail rows
    maxPages: 10,
    scaleMode: gridPdf.ScaleMode.PageWidth,
    documentOptions: {
      compress: true,
      header: {
        declarative: {
          text: '\t&[Page] of &[Pages]'
        }
      },
      footer: {
        declarative: {
          text: '\t&[Page] of &[Pages]'
        }
      },
      info: {
        author: 'C1',
        title: 'HtmlDeetail'
      }
    },
    formatItem: function(args) { // render the row details into the document
      if (args.panel.cellType === grid.CellType.Cell) {
        var row = args.panel.rows[args.row];
        if (row instanceof detail.DetailRow) {
          var detail = core.Control.getControl(row.detail),
            doc = args.canvas.document,
            clr = args.clientRect,
            cnr = args.contentRect;

          doc.saveState();
          args.canvas.paths.rect(clr.left, clr.top, clr.width, clr.height).clip();
          girdpdf.FlexGridPdfConverter.drawToPosition(
            detail, doc, new core.Point(cnr.left, cnr.top), null, null, {
              customCellContent: true
            });
          doc.restoreState();

          args.cancel = true;
        }
      }
    }
  }
);