EmptyDataState
Options
emptyDataState
emptyDataState.emptyDataState : boolean | object
The emptyDataState option configures the EmptyDataState plugin.
You can set the emptyDataState option to one of the following:
| Setting | Description |
|---|---|
false | Disable the EmptyDataState plugin |
true | Enable the EmptyDataState plugin |
| An object | Enable the EmptyDataState plugin with custom settings |
If you set the emptyDataState option to an object, you can configure the following settings:
| Property | Possible values | Description |
|---|---|---|
message | string | object | function | Message to display in the empty data state overlay. |
If you set the message option to an object, it have following properties:
| Property | Possible values | Description |
|---|---|---|
title | string | Title to display in the empty data state overlay. |
description | string | Description to display in the empty data state overlay. |
buttons | array | Buttons to display in the empty data state overlay. |
loading | boolean | When true, shows a loading spinner (used for server fetch state). |
If you set the message option to a function, the source argument can be "unknown", "filters", or "loading".
With [[Options#dataProvider]], the "loading" branch follows DataProvider fetch hooks (beforeDataProviderFetch,
afterDataProviderFetch, and related hooks) using the same rules as server-backed loading in the DataProvider plugin.
Internal refetches (for example after column sort or CRUD) set skipLoading on [[Hooks#beforeDataProviderFetch]] so the
EmptyDataState plugin can omit the loading overlay for those requests.
If you set the buttons option to an array, each item requires following properties:
| Property | Possible values | Description |
|---|---|---|
text | string | Text to display in the button. |
type | ’primary’ | ‘secondary’ | Type of the button. |
callback | function | Callback function to call when the button is clicked. |
Read more:
This option can only be set at the grid level.
It has no effect when set in the columns, cells, or cell options.
Default: false
Since: 16.2.0
Example
// Enable empty data state plugin with default messagesemptyDataState: true,
// Enable empty data state plugin with custom messageemptyDataState: { message: 'No data available',},
// Enable empty data state plugin with custom message and buttons for any sourceemptyDataState: { message: { title: 'No data available', description: 'There’s nothing to display yet.', buttons: [{ text: 'Reset filters', type: 'secondary', callback: () => {} }], },},
// Enable empty data state plugin with custom message and buttons for specific sourceemptyDataState: { message: (source) => { switch (source) { case "filters": return { title: 'No data available', description: 'There’s nothing to display yet.', buttons: [{ text: 'Reset filters', type: 'secondary', callback: () => {} }], }; case "loading": return { title: 'Loading data', description: 'Please wait.', }; default: return { title: 'No data available', description: 'There’s nothing to display yet.', }; } },},Members
DEFAULT_SETTINGS
EmptyDataState.DEFAULT_SETTINGS
Returns the default settings applied when the plugin is enabled without explicit configuration.
PLUGIN_KEY
EmptyDataState.PLUGIN_KEY
Returns the plugin key used to identify this plugin in Handsontable settings.
PLUGIN_PRIORITY
EmptyDataState.PLUGIN_PRIORITY
Returns the priority order used to determine the order in which plugins are initialized.
SETTINGS_VALIDATORS
EmptyDataState.SETTINGS_VALIDATORS
Returns validator functions for each plugin setting to verify their values are valid before applying them.
Methods
destroy
emptyDataState.destroy()
Destroy plugin instance.
disablePlugin
emptyDataState.disablePlugin()
Disable plugin for this Handsontable instance.
enablePlugin
emptyDataState.enablePlugin()
Enable plugin for this Handsontable instance.
isEnabled
emptyDataState.isEnabled() ⇒ boolean
Check if the plugin is enabled in the handsontable settings.
isVisible
emptyDataState.isVisible() ⇒ boolean
Check if the plugin is currently visible.
updatePlugin
emptyDataState.updatePlugin()
Update plugin state after Handsontable settings update.