Class: AutoColumnSize

AutoColumnSize

handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 61

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

By default, the plugin is declared as undefined, which makes it enabled (same as if it was declared as true).
Enabling this plugin may decrease the overall table performance, as it needs to calculate the widths of all cells to
resize the columns accordingly.
If you experience problems with the performance, try turning this feature off and declaring the column widths manually.

Column width calculations are divided into sync and async part. Each of this parts has their own advantages and
disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
block the browser UI.

To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value to a config object:

...
// as a number (300 columns in sync, rest async)
autoColumnSize: {syncLimit: 300},
...

...
// as a string (percent)
autoColumnSize: {syncLimit: '40%'},
...

To configure this plugin see Options#autoColumnSize.

Example
...
var hot = new Handsontable(document.getElementById('example'), {
  date: getData(),
  autoColumnSize: true
});
// Access to plugin instance:
var plugin = hot.getPlugin('autoColumnSize');

plugin.getColumnWidth(4);

if (plugin.isEnabled()) {
  // code...
}
...

Members

firstCalculationBoolean

true only if the first calculation was performed

ghostTableGhostTable

Instance of GhostTable for rows and columns size calculations.

inProgressBoolean

true if the size calculation is in progress.

samplesGeneratorSamplesGenerator

Instance of SamplesGenerator for generating samples necessary for columns width calculations.

widthsArray

Cached columns widths.

Methods

handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 183

calculateAllColumnsWidth(rowRange)

Calculate all columns width.

Parameters:
Name Type Description
rowRange Object | Number

Row range object.

handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 157

calculateColumnsWidth(colRange, rowRange, force)

Calculate a columns width.

Parameters:
Name Type Default Description
colRange Number | Object

Column range object.

rowRange Number | Object

Row range object.

force Boolean false optional

If true force calculate width even when value was cached earlier.

handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 328

clearCache()

Clear cached widths.

handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 411

destroy()

Destroy plugin instance.

handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 146

disablePlugin()

Disable plugin for this Handsontable instance.

handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 119

enablePlugin()

Enable plugin for this Handsontable instance.

handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 275

getColumnWidth(col, defaultWidth, keepMinimum){Number}

Get the calculated column width.

Parameters:
Name Type Default Description
col Number

Column index.

defaultWidth Number optional

Default column width. It will be picked up if no calculated width found.

keepMinimum Boolean true optional

If true then returned value won't be smaller then 50 (default column width).

Returns: {Number}
handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 294

getFirstVisibleColumn(){Number}

Get the first visible column.

Returns: {Number} Returns column index or -1 if table is not rendered.
handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 312

getLastVisibleColumn(){Number}

Get the last visible column.

Returns: {Number} Returns column index or -1 if table is not rendered.
handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 249

getSyncCalculationLimit(){Number}

Get value which tells how many columns should be calculated synchronously. Rest of the columns will be calculated asynchronously.

Returns: {Number}
handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 112

isEnabled(){Boolean}

Check if the plugin is enabled in the handsontable settings.

Returns: {Boolean}
handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 337

isNeedRecalculate(){Boolean}

Check if all widths were calculated. If not then return true (need recalculate).

Returns: {Boolean}
handsontable/src/plugins/autoColumnSize/autoColumnSize.js, line 237

recalculateAllColumnsWidth()

Recalculate all columns width (overwrite cache values).