React Data GridStretchColumns

Description

This plugin allows to set column widths based on their widest cells.

By default, the plugin is declared as 'none', which makes it disabled (same as if it was declared as false).

The plugin determines what happens when the declared grid width is different from the calculated sum of all column widths.

// fit the grid to the container, by stretching only the last column
stretchH: 'last',

// fit the grid to the container, by stretching all columns evenly
stretchH: 'all',

To configure this plugin see Options#stretchH.

Example

const hotRef = useRef(null);

...

// First, let's construct Handsontable
<HotTable
  ref={hotRef}
  data={getData()}
  stretchH={'all'}
/>

Methods

destroy

Source code

stretchColumns.destroy()

Destroys the plugin instance.

disablePlugin

Source code

stretchColumns.disablePlugin()

Disables the plugin functionality for this Handsontable instance.

enablePlugin

Source code

stretchColumns.enablePlugin()

Enables the plugin functionality for this Handsontable instance.

getColumnWidth

Source code

stretchColumns.getColumnWidth(columnVisualIndex) ⇒ number | null

Gets the calculated column width based on the stretching strategy defined by Options#stretchH option.

Param Type Description
columnVisualIndex number The visual index of the column.

isEnabled

Source code

stretchColumns.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 #enablePlugin method is called.

updatePlugin

Source code

stretchColumns.updatePlugin()

Updates the plugin's state. This method is executed when Core#updateSettings is invoked.