Data action provides a way to process a collection of data records in an extensible way.
The data action is defined by the Data
interface, which has two important methods: is
and on
.
is
will be invoked to check whether the action can process the data. Non-supported data actions will be hidden in the runtime.Supported on
will be invoked when a user clicks the data action.Execute
Both methods receive an array of Data
instance, which contain the data source, the optional data record array, and fields.
These two methods receive the Data
and widget
parameters too. The Data
is used to indicate whether the Data
contains all records or a subset of the records.
The framework provides data actions, such as export to CSV and export to JSON. Widgets can provide data actions as well. For instance, the Map widget provides the "pan to" and "zoom to" data actions. Data actions can be implemented in a widget by declaring the data actions in the manifest.json
and creating a class that extends the Abstract
.
Some data actions may need to have a setting UI to configure the action behavior. To achieve this, you can declare the setting
in manifest.json.
An action setting UI component is a React component with some injected props. When the user changes the config, you should call this.props.on
to save the config, which will be available in the on
method.
"dataActions": [
{
"name": "showOnMap",
"label": "Show on map",
"uri": "data-actions/show-on-map",
"settingUri": "data-actions/show-on-map-setting",
"icon": "runtime/assets/icons/ds-map-view.svg"
}
]
Besides providing data actions, a widget can use data action as well. To use the data actions in a widget, you should declare can
in widget manifest.json
properties, then import {
and render the Data
in the widget UI.