Plugin allows to hide certain columns. The hiding is achieved by not rendering the columns. The plugin not modifies
the source data and do not participate in data transformation (the shape of data returned by getData*
methods stays intact).
Possible plugin settings:
copyPasteEnabled
asBoolean
(defaulttrue
)columns
asArray
indicators
asBoolean
(defaultfalse
).
Example
const container = document.getElementById('example');
const hot = new Handsontable(container, {
data: getData(),
hiddenColumns: {
copyPasteEnabled: true,
indicators: true,
columns: [1, 2, 5]
}
});
// access to hiddenColumns plugin instance:
const hiddenColumnsPlugin = hot.getPlugin('hiddenColumns');
// show single column
hiddenColumnsPlugin.showColumn(1);
// show multiple columns
hiddenColumnsPlugin.showColumn(1, 2, 9);
// or as an array
hiddenColumnsPlugin.showColumns([1, 2, 9]);
// hide single column
hiddenColumnsPlugin.hideColumn(1);
// hide multiple columns
hiddenColumnsPlugin.hideColumn(1, 2, 9);
// or as an array
hiddenColumnsPlugin.hideColumns([1, 2, 9]);
// rerender the table to see all changes
hot.render();
Methods
-
destroy()
-
Destroys the plugin instance.
-
disablePlugin()
-
Disables the plugin functionality for this Handsontable instance.
-
enablePlugin()
-
Enables the plugin functionality for this Handsontable instance.
-
getHiddenColumns(){Array.<number>}
-
Returns an array of visual indexes of hidden columns.
Returns: {Array.<number>}
-
hideColumn(column)
-
Hides a single column.
Parameters:
Name Type Description column
number repeatable Visual column index.
-
hideColumns(columns)
-
Hides the columns provided in the array.
Parameters:
Name Type Description columns
Array.<number> Array of visual column indexes.
-
isEnabled(){boolean}
-
Checks if the plugin is enabled in the handsontable settings. This method is executed in
Hooks#beforeInit
hook and if it returnstrue
than theHiddenColumns#enablePlugin
method is called.Returns: {boolean}
-
isHidden(column){boolean}
-
Checks if the provided column is hidden.
Parameters:
Name Type Description column
number Visual column index.
Returns: {boolean}
-
isValidConfig(hiddenColumns){boolean}
-
Get if trim config is valid. Check whether all of the provided column indexes are within the bounds of the table.
Parameters:
Name Type Description hiddenColumns
Array List of hidden column indexes.
Returns: {boolean}
-
showColumn(column)
-
Shows a single column.
Parameters:
Name Type Description column
number repeatable Visual column index.
-
showColumns(columns)
-
Shows the provided columns.
Parameters:
Name Type Description columns
Array.<number> Array of visual column indexes.
-
updatePlugin()
-
Updates the plugin state. This method is executed when
Core#updateSettings
is invoked.