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 onExport function that is automatically invoked by AdapTable
    • an Adaptable Form when bespoke information is required by the runtime user prior to export

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

User-provided Report Destinations (used in addition to those shipped in AdapTable)

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:

PropertyDescription
formOptional Adaptable Form; if provided, it must include Buttons that will execute the Export
nameName of Custom Destination (mandatory)
onExportOptional 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 onExport function 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

Custom Export Destination via Function
Fork
  • This example contains a Custom Export Destination - Rest Endpoint
  • It provides an implementation for the onExport function, 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

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 onClick function 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
Custom Export Destination via a Form
Fork
  • This example contains a Custom Export Destination - Email which 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 Export button cannot be clicked if the Email Body input is blank
  • The onClick property of the Export Button 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

Custom Export Destinations

(Recorded with AdapTable v13.1)