Custom Export Destinations
Summary
- AdapTable System Export Destinations can be supplemented by Custom Destinations provided by developers
- Custom Destinations can be provided by Developers in 2 ways:
- an
onExportfunction that is automatically invoked by AdapTable - an Adaptable Form when bespoke information is required by the runtime user prior to export
- an
If the System Export Destinations provided by AdapTable are insufficient, developers can easily supply their own custom export destinations.
This is done via the customDestinations property in Export Options.
The property returns a list (either directly or via a function) of which Custom Destinations are available.
customDestinations
Note
- This allows you to export grid data to email, PDF, REST Apis and other locations you require
- And you can still leverage AdapTable's Reports, Expressions, Scheduling and State Management functionality
Defining a Custom Destination
The Custom Destination object is defined as follows:
| Property | Description |
|---|---|
| form | Optional Adaptable Form; if provided, it must include Buttons that will execute the Export |
| name | Name of Custom Destination (mandatory) |
| onExport | Optional Function invoked when Export is applied (used if no form is supplied) |
As can be seen, it has a mandatory name property, and depending on the complexity required, there are 2 (mutually exclusive) ways of providing the Custom Destination implementation:
- an
onExportfunction that is invoked by AdapTable automatically - an Adaptable Form if bespoke information is required by the runtime user prior to export
Using an onExport function
In this use case, the developer needs to provide an implementation for the onExport function.
This function will then be invoked by AdapTable whenever a report is exported to the Custom Destination.
Deep Dive
Using the onExport function
- This example contains a Custom Export Destination -
Rest Endpoint - It provides an implementation for the
onExportfunction, that is invoked when the Report runs - Note: the demo simply sends a System Status message with the Report's name (and console logs its data), but a "real world" application's implementation would send the data to a REST endpoint
Defining an AdapTable Form
It might sometimes be necessary for users to provide additional information regarding the custom destination e.g. an email address.
This is done by including an Adaptable Form definition in the Custom Destination.
AdapTable will read this form definition metadata and display the form dynamically (including default values).
Find Out More
See Guide to defining an Adaptable Form for full details
The form can include as many field definitions as required, together with optional default values if needed.
For the form to be effective it must include a Submit Button with an onClick property that performs the Export.
Caution
- When providing a form AdapTable will not perform the Export automatically
- It is your responsibility to provide a button with an
onClickfunction which will export the data
Deep Dive
Providing an AdapTable Form
Note
- Custom Destination can also be included in a Scheduled Export
- The same dynamic form and its associated form fields and buttons will be displayed in the Schedule Wizard
- This example contains a Custom Export Destination -
Emailwhich uses an Adaptable Form that displays automatically when the Export is invoked - The Form contains a number of input fields:
- Dropdown with pre-selected Email Addresses
- Textboxes for Subject (pre-populated) and Body
- Checkbox for Including Headers
- The Form also contains validation - the
Exportbutton cannot be clicked if the Email Body input is blank - The
onClickproperty of theExportButton simply sends the data as a System Status (but a real world example will be different) - We also removed all System Export Destinations so that only the Custom Destination is available