Skip to content

EmptyDataState

Options

emptyDataState

Source code

emptyDataState.emptyDataState : boolean | object

The emptyDataState option configures the EmptyDataState plugin.

You can set the emptyDataState option to one of the following:

SettingDescription
falseDisable the EmptyDataState plugin
trueEnable the EmptyDataState plugin
An objectEnable the EmptyDataState plugin with custom settings

If you set the emptyDataState option to an object, you can configure the following settings:

PropertyPossible valuesDescription
messagestring | object | functionMessage to display in the empty data state overlay.

If you set the message option to an object, it have following properties:

PropertyPossible valuesDescription
titlestringTitle to display in the empty data state overlay.
descriptionstringDescription to display in the empty data state overlay.
buttonsarrayButtons to display in the empty data state overlay.
loadingbooleanWhen 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:

PropertyPossible valuesDescription
textstringText to display in the button.
type’primary’ | ‘secondary’Type of the button.
callbackfunctionCallback 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 messages
emptyDataState: true,
// Enable empty data state plugin with custom message
emptyDataState: {
message: 'No data available',
},
// Enable empty data state plugin with custom message and buttons for any source
emptyDataState: {
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 source
emptyDataState: {
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

Source code

EmptyDataState.DEFAULT_SETTINGS

Returns the default settings applied when the plugin is enabled without explicit configuration.

PLUGIN_KEY

Source code

EmptyDataState.PLUGIN_KEY

Returns the plugin key used to identify this plugin in Handsontable settings.

PLUGIN_PRIORITY

Source code

EmptyDataState.PLUGIN_PRIORITY

Returns the priority order used to determine the order in which plugins are initialized.

SETTINGS_VALIDATORS

Source code

EmptyDataState.SETTINGS_VALIDATORS

Returns validator functions for each plugin setting to verify their values are valid before applying them.

Methods

destroy

Source code

emptyDataState.destroy()

Destroy plugin instance.

disablePlugin

Source code

emptyDataState.disablePlugin()

Disable plugin for this Handsontable instance.

enablePlugin

Source code

emptyDataState.enablePlugin()

Enable plugin for this Handsontable instance.

isEnabled

Source code

emptyDataState.isEnabled() ⇒ boolean

Check if the plugin is enabled in the handsontable settings.

isVisible

Source code

emptyDataState.isVisible() ⇒ boolean

Check if the plugin is currently visible.

updatePlugin

Source code

emptyDataState.updatePlugin()

Update plugin state after Handsontable settings update.