Skip to content

ManualColumnResize

Description

Initializes the plugin and creates the resize gesture.

Options

manualColumnResize

Can be set at: grid

Source code

manualColumnResize.manualColumnResize : boolean | Array<number>

The manualColumnResize option configures the ManualColumnResize plugin.

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

SettingDescription
trueEnable the ManualColumnResize plugin
falseDisable the ManualColumnResize plugin
An array- Enable the ManualColumnResize plugin
- Set initial widths of individual columns

Read more:

When you set initial widths through the array form, those columns are excluded from stretchH redistribution. Only the columns without a pre-defined width are stretched.

This option can only be set at the grid level. It has no effect when set in the columns, cells, or cell options.

Default: undefined
Example

// enable the `manualColumnResize` plugin
manualColumnResize: true,
// enable the `manualColumnResize` plugin
// set the initial width of column 0 to 40 pixels
// set the initial width of column 1 to 50 pixels
// set the initial width of column 2 to 60 pixels
manualColumnResize: [40, 50, 60],

Members

PLUGIN_KEY

Source code

ManualColumnResize.PLUGIN_KEY

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

PLUGIN_PRIORITY

Source code

ManualColumnResize.PLUGIN_PRIORITY

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

SETTING_KEYS

Source code

ManualColumnResize.SETTING_KEYS ⇒ Array<string>

Returns the setting keys that trigger a plugin update after an updateSettings() call. The colWidths option is listed alongside the plugin’s own key, so that re-declaring the column widths discards the widths kept from earlier manual resizing.

Methods

clearManualSize

Source code

manualColumnResize.clearManualSize(column)

Clears the width stored for the specified column, so the column falls back to the width coming from the colWidths option, or to the built-in default width. Call render() afterwards to repaint the grid.

Example

const resizePlugin = hot.getPlugin('manualColumnResize');
resizePlugin.clearManualSize(0);
hot.render();
ParamTypeDescription
columnnumberVisual column index.

clearManualSizes

Source code

manualColumnResize.clearManualSizes()

Clears the widths stored for every column, so the columns fall back to the widths coming from the colWidths option, or to the built-in default width. Call render() afterwards to repaint the grid.

Example

const resizePlugin = hot.getPlugin('manualColumnResize');
resizePlugin.clearManualSizes();
hot.render();

destroy

Source code

manualColumnResize.destroy()

Destroys the plugin instance.

disablePlugin

Source code

manualColumnResize.disablePlugin()

Disables the plugin functionality for this Handsontable instance.

enablePlugin

Source code

manualColumnResize.enablePlugin()

Enables the plugin functionality for this Handsontable instance.

getManualSize

Source code

manualColumnResize.getManualSize(column) ⇒ number | null

Returns the width set manually for the specified column, or null when the column was never resized by hand and takes its width from elsewhere.

ParamTypeDescription
columnnumberVisual column index.

getManualSizes

Source code

manualColumnResize.getManualSizes() ⇒ Array<Array<number>>

Returns every width set manually, as [physicalColumn, width] pairs. Physical indexes, because the map stores them that way: a manually resized column that trimming has taken out of the visual space still carries its width here, while getManualSize cannot reach it.

Returns: Array<Array<number>> - The stored [physicalColumn, width] pairs.

isEnabled

Source code

manualColumnResize.isEnabled() ⇒ boolean

Checks if the plugin is enabled in the handsontable settings. This method is executed in Hooks#beforeInit hook and if it returns true then the ManualColumnResize#enablePlugin method is called.

loadManualColumnWidths Deprecated

Source code

manualColumnResize.loadManualColumnWidths() ⇒ Array

Deprecated. The `PersistentState` plugin has been removed. This method is a no-op.

saveManualColumnWidths Deprecated

Source code

manualColumnResize.saveManualColumnWidths()

Deprecated. The `PersistentState` plugin has been removed. This method is a no-op.

setManualSize

Source code

manualColumnResize.setManualSize(column, width) ⇒ number

Sets the new width for the specified visual column index.

This method updates the plugin’s internal width map. Call render() after setManualSize() to repaint the grid. Values lower than 20px are saved as 20px.

Example

const resizePlugin = hot.getPlugin('manualColumnResize');
resizePlugin.setManualSize(0, 120);
hot.render();
ParamTypeDescription
columnnumberVisual column index.
widthnumberColumn width (no less than 20px).

Returns: number - Returns new width.

setManualSizes

Source code

manualColumnResize.setManualSizes(sizes)

Writes a set of manual widths at once, addressed by physical column index — the counterpart of ManualColumnResize#getManualSizes, so a stored set round-trips onto the same records regardless of trimming or column order. Values lower than 20px are saved as 20px, and an index outside the current column count is skipped. Call render() afterwards to repaint the grid.

ParamTypeDescription
sizesArray<Array<number>>The [physicalColumn, width] pairs to write.

updatePlugin

Source code

manualColumnResize.updatePlugin([newSettings])

Updates the plugin’s state.

This method is executed when updateSettings() is invoked with any of the following configuration options:

Passing colWidths re-declares the column widths, so the widths kept from earlier manual resizing are discarded. A grid whose manualColumnResize option is an array keeps that array instead, whether the array arrives in this call or was set when the grid was built.

ParamTypeDescription
[newSettings]objectoptional The config object passed to updateSettings().