Skip to content

AutoRowSize

Description

Initializes the plugin, registers the row heights map, and sets up the row resize hook.

Options

autoRowSize

Source code

autoRowSize.autoRowSize : object | boolean

The autoRowSize option configures the AutoRowSize plugin.

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

SettingDescription
falseDisable the AutoRowSize plugin
trueEnable the AutoRowSize plugin with the default configuration
An objectEnable the AutoRowSize plugin and modify the plugin options

To give Handsontable’s scrollbar a proper size, set the autoRowSize option to true.

If you set the autoRowSize option to an object, you can set the following AutoRowSize plugin options:

PropertyPossible valuesDescription
syncLimitA number | A percentage stringThe number/percentage of rows to keep in sync
(default: 500)
samplingRatioA numberThe number of samples of the same length to be used in row height calculations
allowSampleDuplicatestrue | falseWhen calculating row heights:
true: Allow duplicate samples
false: Don’t allow duplicate samples

Using the rowHeights option forcibly disables the AutoRowSize plugin.

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: undefined
Example

autoRowSize: {
// keep 40% of rows in sync (the rest of rows: async)
syncLimit: '40%',
// when calculating row heights, use 10 samples of the same length
samplingRatio: 10,
// when calculating row heights, allow duplicate samples
allowSampleDuplicates: true
},

Members

CALCULATION_STEP

Source code

AutoRowSize.CALCULATION_STEP

Returns the number of rows processed in a single calculation step during asynchronous sizing.

DEFAULT_SETTINGS

Source code

AutoRowSize.DEFAULT_SETTINGS

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

inProgress

Source code

autoRowSize.inProgress : boolean

true if the size calculation is in progress.

measuredRows

Source code

autoRowSize.measuredRows : number

Number of already measured rows (we already know their sizes).

PLUGIN_KEY

Source code

AutoRowSize.PLUGIN_KEY

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

PLUGIN_PRIORITY

Source code

AutoRowSize.PLUGIN_PRIORITY

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

SETTING_KEYS

Source code

AutoRowSize.SETTING_KEYS

Returns true so the plugin updates on every updateSettings call, regardless of config object contents.

SYNC_CALCULATION_LIMIT

Source code

AutoRowSize.SYNC_CALCULATION_LIMIT

Returns the maximum number of rows whose heights are calculated synchronously before switching to async mode.

Methods

calculateAllRowsHeight

Source code

autoRowSize.calculateAllRowsHeight(colRange, [overwriteCache])

Calculate all rows heights. The calculated row will be cached in the AutoRowSize#heights property. To retrieve height for specified row use AutoRowSize#getRowHeight method.

ParamTypeDefaultDescription
colRangeobject
number
Row index or an object with from and to properties which define row range.
[overwriteCache]booleanfalseoptional If true the calculation will be processed regardless of whether the width exists in the cache.

calculateRowsHeight

Source code

autoRowSize.calculateRowsHeight(rowRange, colRange, [overwriteCache])

Calculate a given rows height.

ParamTypeDefaultDescription
rowRangenumber
object
Row index or an object with from and to indexes as a range.
colRangenumber
object
Column index or an object with from and to indexes as a range.
[overwriteCache]booleanfalseoptional If true the calculation will be processed regardless of whether the width exists in the cache.

calculateVisibleRowsHeight

Source code

autoRowSize.calculateVisibleRowsHeight()

Calculates heights for visible rows in the viewport only.

clearCache

Source code

autoRowSize.clearCache([physicalRows])

Clears cache of calculated row heights. If you want to clear only selected rows pass an array with their indexes. Otherwise whole cache will be cleared.

ParamTypeDescription
[physicalRows]Array<number>optional List of physical row indexes to clear.

clearCacheByRange

Source code

autoRowSize.clearCacheByRange(range)

Clears cache by range.

ParamTypeDescription
rangeobject
number
Row index or an object with from and to properties which define row range.

destroy

Source code

autoRowSize.destroy()

Destroys the plugin instance.

disablePlugin

Source code

autoRowSize.disablePlugin()

Disables the plugin functionality for this Handsontable instance.

enablePlugin

Source code

autoRowSize.enablePlugin()

Enables the plugin functionality for this Handsontable instance.

getColumnHeaderHeight

Source code

autoRowSize.getColumnHeaderHeight() ⇒ number | undefined

Get the calculated column header height.

getFirstVisibleRow

Source code

autoRowSize.getFirstVisibleRow() ⇒ number

Get the first visible row.

When the MergeCells plugin is enabled with its default virtualized: false setting, a merged cell that crosses the viewport edge extends the rendered row range. In that case this method can return a row index outside the strictly visible viewport. To read the actual visible viewport, use Core#getFirstFullyVisibleRow or Core#getFirstPartiallyVisibleRow.

Returns: number - Returns row index, -1 if table is not rendered or if there are no rows to base the the calculations on.

getLastVisibleRow

Source code

autoRowSize.getLastVisibleRow() ⇒ number

Gets the last visible row.

When the MergeCells plugin is enabled with its default virtualized: false setting, a merged cell that crosses the viewport edge extends the rendered row range. In that case this method can return a row index outside the strictly visible viewport. To read the actual visible viewport, use Core#getLastFullyVisibleRow or Core#getLastPartiallyVisibleRow.

Returns: number - Returns row index or -1 if table is not rendered.

getRowHeight

Source code

autoRowSize.getRowHeight(row, [defaultHeight]) ⇒ number

Get a row’s height, as measured in the DOM.

The height returned includes 1 px of the row’s bottom border.

Mind that this method is different from the getRowHeight() method of Handsontable’s Core.

ParamTypeDescription
rownumberA visual row index.
[defaultHeight]numberoptional If no height is found, defaultHeight is returned instead.

Returns: number - The height of the specified row, in pixels.

getSyncCalculationLimit

Source code

autoRowSize.getSyncCalculationLimit() ⇒ number

Gets value which tells how many rows should be calculated synchronously (rest of the rows will be calculated asynchronously). The limit is calculated based on syncLimit set to autoRowSize option (see Options#autoRowSize).

isEnabled

Source code

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

isNeedRecalculate

Source code

autoRowSize.isNeedRecalculate() ⇒ boolean

Checks if all heights were calculated. If not then return true (need recalculate).

recalculateAllRowsHeight

Source code

autoRowSize.recalculateAllRowsHeight()

Recalculates all rows height (overwrite cache values).