Processing Reports
Summary
- Developers can "process" (i.e. intercept) a report before it is evaluated and exported
- This is used in 3 main use cases:
- running the report on the server and sending the data back to AdapTable
- cancelling a proposed Export
- providing entirely new column and row data
All AdapTable reports can be processed before they are exported.
This allows developers to provide a function implementation enabling them to:
- evaluate the Report on the server (typically when using the Server-Side Row Model)
- configure whether the Export should take place
- provide a changed (or, indeed, entirely different) set of report data
Caution
Processing should be avoided when using the VisualExcel Report Format
Processing is configured using the processExport property in Export Options which can return 3 values:
ExportResultDataobject (provided on Server) - will be used as data for Report and exported by AdapTabletrue- Report will be evaluated by AdapTable as normal, using Grid data (provided by AdapTableQL)false- the export will be cancelled and no report will run
processExport
Promise<ExportResultData | boolean>Exporting via the Server
The most common use case for processing reports is when running export on the server.
Hint
This most typically happens when using the Server-Side Row Model
Developers can evaluate the report on the server, and return the report data to AdapTable for it to export to the selected destination.
- This demo illustrates how to use the
processExportproperty in Export Options to create report data on the Server and return to AdapTable to export - It is taken from the more extensive Server-Side Row Model Demo focussing purely on Export
- Both the (System) 'All Data', and the (Custom) 'US Golden Athletes' Reports are evaluated on the server, and the data is sent back to AdapTable to export
- Run the 'All Data' or 'US Golden Athletes' Reports and note how the data is provided 'on the server' and then send back to AdapTable
Cancelling an Export
Because the function can return a boolean, this can be leveraged to set whether the proposed Report runs.
This allows developers to decide dynamically whether or not the user can run the given report.
Hint
The boolean value can be returned asynchronously if required, allowing server permission checks
- This demo illustrates how to use the
processExportproperty in Export Options to stop a particular Report from being run. - We do not allow the
Current Layoutreport to be run (and output a System Status Message to that effect)
- Run the 'Current Layout' Report and note that the export is prevented (with a System Status Message displayed)
- Switch to a different Report and this time the export works as normal
Changing Report Data
The processExport function can also be used to change the data that will be displayed in the Report.
Use it to build the rows and columns for a Report and return them as an ExportResultData object.
AdapTable exports that data to the selected destination.
Hint
- A Layout with Row Summaries is a common use case, as AG Grid includes those pinned rows in the All Data report
- If that is unwanted, use this function to strip out Row Summaries and return remaining data so export continues
- This demo shows a Layout with a Top and a Bottom Row Summary
- The Export toolbar is open, and the current report is
All Data(CSV) - For the
All Datareport,processExportkeeps every data row, skips each Row Summary, and returns the report in the selected format - Any other report returns
true, so AdapTable exports it in the normal way, Row Summaries included
- Run the
All Datareport and open the file: the two summary rows are absent - Switch to
Current Layoutand run it again: the summary rows are in the file