Methods
-
add(key, callback, context){Hooks}
-
Adds a listener (globally or locally) to a specified hook name.
If thecontextparameter is provided, the hook will be added only to the instance it references.
Otherwise, the callback will be used everytime the hook fires on any Handsontable instance.
You can provide an array of callback functions as thecallbackargument, this way they will all be fired
once the hook is triggered.Parameters:
Name Type Default Description keyString Hook name.
callbackfunction | Array Callback function or an array of functions.
contextObject optional The context for the hook callback to be added - a Handsontable instance or leave empty.
- See:
Returns: {Hooks} Instance of Hooks.
Example
// single callback, added locally Handsontable.hooks.add('beforeInit', myCallback, hotInstance); // single callback, added globally Handsontable.hooks.add('beforeInit', myCallback); // multiple callbacks, added locally Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback], hotInstance); // multiple callbacks, added globally Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback]); -
createEmptyBucket(){Object}
-
Returns a new object with empty handlers related to every registered hook name.
Returns: {Object} The empty bucket object.
Example
Handsontable.hooks.createEmptyBucket(); // Results: { ... afterCreateCol: [], afterCreateRow: [], beforeInit: [], ... } -
deregister(key)
-
Deregisters a hook name (removes it from the list of known hook names).
Parameters:
Name Type Description keyString Hook name.
Example
Handsontable.hooks.deregister('myHook'); -
destroy(context)
-
Destroy all listeners connected to the context. If no context is provided, the global listeners will be destroyed.
Parameters:
Name Type Default Description contextObject optional A Handsontable instance.
Example
// destroy the global listeners Handsontable.hooks.destroy(); // destroy the local listeners Handsontable.hooks.destroy(hotInstance); -
getBucket(context){Object}
-
Get hook bucket based on the context of the object or if argument is
undefined, get the global hook bucket.Parameters:
Name Type Default Description contextObject optional A Handsontable instance.
Returns: {Object} Returns a global or Handsontable instance bucket.
-
getRegistered(){Array}
-
Returns an array of registered hooks.
Returns: {Array} An array of registered hooks.
Example
Handsontable.hooks.getRegistered(); // Results: [ ... 'beforeInit', 'beforeRender', 'beforeSetRangeEnd', 'beforeDrawBorders', 'beforeChange', ... ] -
has(key, context){Boolean}
-
Checks whether there are any registered listeners for the provided hook name.
If thecontextparameter is provided, it only checks for listeners assigned to the given Handsontable instance.Parameters:
Name Type Default Description keyString Hook name.
contextObject optional A Handsontable instance.
Returns: {Boolean}
truefor success,falseotherwise. -
isRegistered(key){Boolean}
-
Returns a boolean depending on if a hook by such name has been registered.
Parameters:
Name Type Description keyString Hook name.
Returns: {Boolean}
truefor success,falseotherwise.Example
Handsontable.hooks.isRegistered('beforeInit'); // Results: true -
once(key, callback, context)
-
Adds a listener to a specified hook. After the hook runs this listener will be automatically removed from the bucket.
Parameters:
Name Type Default Description keyString Hook/Event name.
callbackfunction | Array Callback function.
contextObject optional A Handsontable instance.
- See:
Example
Handsontable.hooks.once('beforeInit', myCallback, hotInstance); -
register(key)
-
Registers a hook name (adds it to the list of the known hook names). Used by plugins.
It is not necessary to call register, but if you use it, your plugin hook will be used returned by
thegetRegisteredmethod. (which itself is used in the demo tutorial-callbacks.html).Parameters:
Name Type Description keyString The hook name.
Example
Handsontable.hooks.register('myHook'); -
remove(key, callback, context){Boolean}
-
Removes a listener from a hook with a given name. If the
contextargument is provided, it removes a listener from a local hook assigned to the given Handsontable instance.Parameters:
Name Type Default Description keyString Hook/Event name.
callbackfunction Callback function (needs the be the function that was previously added to the hook).
contextObject optional Handsontable instance.
- See:
Returns: {Boolean} Returns
trueif hook was removed,falseotherwise.Example
Handsontable.hooks.remove('beforeInit', myCallback); -
run(context, key, p1, p2, p3, p4, p5, p6){*}
-
Runs all local and global callbacks assigned to the hook identified by the
keyparameter.
It returns either a return value from the last called callback or the first parameter (p1) passed to therunfunction.Parameters:
Name Type Description contextObject Handsontable instance.
keyString Hook/Event name.
p1* optional Parameter to be passed as an argument to the callback function.
p2* optional Parameter to be passed as an argument to the callback function.
p3* optional Parameter to be passed as an argument to the callback function.
p4* optional Parameter to be passed as an argument to the callback function.
p5* optional Parameter to be passed as an argument to the callback function.
p6* optional Parameter to be passed as an argument to the callback function.
- See:
Returns: {*} Either a return value from the last called callback or
p1.Example
Handsontable.hooks.run(hot, 'beforeInit');
Events
-
afterAddChild
-
Fired by
NestedRowsplugin after adding a children to the NestedRows structure. This hook is fired when
Options#nestedRowsoption is enabled.Parameters:
Name Type Description parentObject The parent object.
elementObject | undefined The element added as a child. If
undefined, a blank child was added.indexNumber | undefined The index within the parent where the new child was added. If
undefined, the element was added as the last child. -
afterBeginEditing
-
Fired after the editor is opened and rendered.
Parameters:
Name Type Description rowNumber Visual row index of the edited cell.
columnNumber Visual column index of the edited cell.
-
afterCellMetaReset
-
Fired after resetting a cell's meta. This happens when the
Core#updateSettingsmethod is called. -
afterChange
-
Fired after one or more cells has been changed. The changes are triggered in any situation when the
value is entered using an editor or changed using API (e.q setDataAtCell)Note: For performance reasons, the
changesarray is null for"loadData"source.Parameters:
Name Type Description changesArray 2D array containing information about each of the edited cells
[[row, prop, oldVal, newVal], ...].sourceString optional String that identifies source of hook call (list of all available sources).
Example
new Handsontable(element, { afterChange: (changes) => { changes.forEach(([row, prop, oldValue, newValue]) => { // Some logic... }); } }) -
afterChangesObserved
-
Fired by
ObserveChangesplugin after detecting changes in the data source. This hook is fired when
Options#observeChangesoption is enabled. -
afterColumnMove
-
Fired by
ManualColumnMoveplugin after changing order of the visual indexes. This hook is fired when
Options#manualColumnMoveoption is enabled.Parameters:
Name Type Description columnsArray.<Number> Array of visual column indexes that were moved.
targetNumber Visual column index being a target for moved columns.
-
afterColumnResize
-
Fired by
ManualColumnResizeplugin after rendering the table with modified column sizes. This hook is
fired whenOptions#manualColumnResizeoption is enabled.Parameters:
Name Type Description currentColumnNumber Visual index of the resized column.
newSizeNumber Calculated new column width.
isDoubleClickBoolean Flag that determines whether there was a double-click.
-
afterColumnSort
-
Fired by
ColumnSortingandMultiColumnSortingplugins after sorting the column. This hook is fired whenOptions#columnSorting
orOptions#multiColumnSortingoption is enabled.Parameters:
Name Type Description currentSortConfigArray Current sort configuration (for all sorted columns).
destinationSortConfigsArray Destination sort configuration (for all sorted columns).
-
afterContextMenuDefaultOptions
-
Fired by
ContextMenuafter setting up the Context Menu's default options. These options are a collection
which user can select by setting an array of keys or an array of objects inOptions#contextMenuoption.Parameters:
Name Type Description predefinedItemsArray An array of objects containing information about the pre-defined Context Menu items.
-
afterContextMenuHide
-
Fired by
ContextMenuplugin after hiding the Context Menu. This hook is fired whenOptions#contextMenu
option is enabled.Parameters:
Name Type Description contextObject The Context Menu plugin instance.
-
afterContextMenuShow
-
Fired by
ContextMenuplugin after opening the Context Menu. This hook is fired whenOptions#contextMenu
option is enabled.Parameters:
Name Type Description contextObject The Context Menu plugin instance.
-
afterCopy
-
Fired by
CopyPasteplugin after data are pasted into table. This hook is fired whenOptions#copyPaste
option is enabled.Parameters:
Name Type Description dataArray.<Array> An array of arrays which contains the copied data.
coordsArray.<Object> An array of objects with ranges of the visual indexes (
startRow,startCol,endRow,endCol)
which was copied. -
afterCopyLimit
-
Fired by
CopyPasteplugin after reaching the copy limit while copying data. This hook is fired when
Options#copyPasteoption is enabled.Parameters:
Name Type Description selectedRowsNumber Count of selected copyable rows.
selectedColumnsNumber Count of selected copyable columns.
copyRowsLimitNumber Current copy rows limit.
copyColumnsLimitNumber Current copy columns limit.
-
afterCreateCol
-
Fired after created a new column.
Parameters:
Name Type Description indexNumber Represents the visual index of first newly created column in the data source.
amountNumber Number of newly created columns in the data source.
sourceString optional String that identifies source of hook call
(list of all available sources). -
afterCreateRow
-
Fired after created a new row.
Parameters:
Name Type Description indexNumber Represents the visual index of first newly created row in the data source array.
amountNumber Number of newly created rows in the data source array.
sourceString optional String that identifies source of hook call
(list of all available sources). -
afterCut
-
Fired by
CopyPasteplugin after data was cut out from the table. This hook is fired when
Options#copyPasteoption is enabled.Parameters:
Name Type Description dataArray.<Array> An array of arrays which contains the cutted out data.
coordsArray.<Object> An array of objects with ranges of the visual indexes (
startRow,startCol,endRow,endCol)
which was cut out. -
afterDeselect
-
Fired after the current cell is deselected.
-
afterDestroy
-
Fired after destroying the Handsontable instance.
-
afterDetachChild
-
Fired by
NestedRowsplugin after detaching a child from its parent. This hook is fired when
Options#nestedRowsoption is enabled.Parameters:
Name Type Description parentObject An object representing the parent from which the element was detached.
elementObject The detached element.
-
afterDocumentKeyDown
-
General hook which captures
keydownevents attached to the document body. These events are delegated to the
hooks system and consumed by Core and internal modules (e.g plugins, editors).Parameters:
Name Type Description eventEvent A native
keydownevent object. -
afterDrawSelection
-
Fired inside the Walkontable's selection
drawmethod. Can be used to add additional class names to cells, depending on the current selection.Parameters:
Name Type Description currentRowNumber Row index of the currently processed cell.
currentColumnNumber Column index of the currently cell.
cornersOfSelectionArray.<Number> Array of the current selection in a form of
[startRow, startColumn, endRow, endColumn].layerLevelNumber | undefined Number indicating which layer of selection is currently processed.
- Since: 0.38.1
Returns: {String|undefined} Can return a
String, which will act as an additionalclassNameto be added to the currently processed cell. -
afterDropdownMenuDefaultOptions
-
Fired by
DropdownMenuplugin after setting up the Dropdown Menu's default options. These options are a
collection which user can select by setting an array of keys or an array of objects inOptions#dropdownMenu
option.Parameters:
Name Type Description predefinedItemsArray.<Object> An array of objects containing information about the pre-defined Context Menu items.
-
afterDropdownMenuHide
-
Fired by
DropdownMenuplugin after hiding the Dropdown Menu. This hook is fired whenOptions#dropdownMenu
option is enabled.Parameters:
Name Type Description instanceDropdownMenu The DropdownMenu instance.
-
afterDropdownMenuShow
-
Fired by
DropdownMenuplugin after opening the Dropdown Menu. This hook is fired whenOptions#dropdownMenu
option is enabled.Parameters:
Name Type Description dropdownMenuDropdownMenu The DropdownMenu instance.
-
afterFilter
-
Fired by
Filtersplugin after applying filtering. This hook is fired when
Options#filtersoption is enabled.Parameters:
Name Type Description conditionsStackArray.<Object> An array of objects with added conditions.
// Example format of the conditionsStack argument: [ { column: 2, conditions: [ {name: 'begins_with', args: [['S']]} ], operation: 'conjunction' }, { column: 4, conditions: [ {name: 'not_empty', args: []} ], operation: 'conjunction' }, ] -
afterGetCellMeta
-
Fired after getting the cell settings.
Parameters:
Name Type Description rowNumber Visual row index.
columnNumber Visual column index.
cellPropertiesObject Object containing the cell properties.
-
afterGetColHeader
-
Fired after retrieving information about a column header and appending it to the table header.
Parameters:
Name Type Description columnNumber Visual column index.
THHTMLTableCellElement Header's TH element.
-
afterGetColumnHeaderRenderers
-
Fired after getting the column header renderers.
Parameters:
Name Type Description renderersArray.<function()> An array of the column header renderers.
-
afterGetRowHeader
-
Fired after retrieving information about a row header and appending it to the table header.
Parameters:
Name Type Description rowNumber Visual row index.
THHTMLTableCellElement Header's TH element.
-
afterGetRowHeaderRenderers
-
Fired after getting the row header renderers.
Parameters:
Name Type Description renderersArray.<function()> An array of the row header renderers.
-
afterInit
-
Fired after the Handsontable instance is initiated.
-
afterLanguageChange
-
Fired after successful change of language (when proper language code was set).
Parameters:
Name Type Description languageCodeString New language code.
- Since: 0.35.0
-
afterListen
-
Fired after the table was switched into listening mode. This allows Handsontable to capture keyboard events and
respond in the right way. -
afterLoadData
-
Fired after new data is loaded (by
loadDataorupdateSettingsmethod) into the data source array.Parameters:
Name Type Description initialLoadBoolean flag that determines whether the data has been loaded during the initialization.
-
afterMergeCells
-
Fired by
MergeCellsplugin after cell merging. This hook is fired whenOptions#mergeCells
option is enabled.Parameters:
Name Type Default Description cellRangeCellRange Selection cell range.
mergeParentObject The parent collection of the provided cell range.
autoBoolean false optional trueif called automatically by the plugin. -
afterModifyTransformEnd
-
Fired after the end of the selection is being modified (e.g. moving the selection with the arrow keys).
Parameters:
Name Type Description coordsCellCoords Visual coords of the freshly selected cell.
rowTransformDirNumber -1if trying to select a cell with a negative row index.0otherwise.colTransformDirNumber -1if trying to select a cell with a negative column index.0otherwise. -
afterModifyTransformStart
-
Fired after the start of the selection is being modified (e.g. moving the selection with the arrow keys).
Parameters:
Name Type Description coordsCellCoords Coords of the freshly selected cell.
rowTransformDirNumber -1if trying to select a cell with a negative row index.0otherwise.colTransformDirNumber -1if trying to select a cell with a negative column index.0otherwise. -
afterMomentumScroll
-
Fired after a scroll event, which is identified as a momentum scroll (e.g. on an iPad).
-
afterOnCellContextMenu
-
Fired after clicking right mouse button on a cell or row/column header.
For example clicking on the row header of cell (0, 0) results with
afterOnCellContextMenucalled
with coordinates{row: 0, col: -1}.Parameters:
Name Type Description eventEvent contextmenuevent object.coordsCellCoords Coordinates object containing the visual row and visual column indexes of the clicked cell.
TDHTMLTableCellElement Cell's TD (or TH) element.
- Since: 4.1.0
-
afterOnCellCornerDblClick
-
Fired after a
dblclickevent is triggered on the cell corner (the drag handle).Parameters:
Name Type Description eventEvent dblclickevent object. -
afterOnCellCornerMouseDown
-
Fired after a
mousedownevent is triggered on the cell corner (the drag handle).Parameters:
Name Type Description eventEvent mousedownevent object. -
afterOnCellMouseDown
-
Fired after clicking on a cell or row/column header. In case the row/column header was clicked, the coordinate
indexes are negative.For example clicking on the row header of cell (0, 0) results with
afterOnCellMouseDowncalled
with coordinates{row: 0, col: -1}.Parameters:
Name Type Description eventEvent mousedownevent object.coordsCellCoords Coordinates object containing the visual row and visual column indexes of the clicked cell.
TDHTMLTableCellElement Cell's TD (or TH) element.
-
afterOnCellMouseOut
-
Fired after leaving a cell or row/column header with the mouse cursor.
Parameters:
Name Type Description eventEvent mouseoutevent object.coordsCellCoords Leaved cell's visual coordinate object.
TDHTMLTableCellElement Cell's TD (or TH) element.
-
afterOnCellMouseOver
-
Fired after hovering a cell or row/column header with the mouse cursor. In case the row/column header was
hovered, the index is negative.For example, hovering over the row header of cell (0, 0) results with
afterOnCellMouseOvercalled
with coords{row: 0, col: -1}.Parameters:
Name Type Description eventEvent mouseoverevent object.coordsCellCoords Hovered cell's visual coordinate object.
TDHTMLTableCellElement Cell's TD (or TH) element.
-
afterOnCellMouseUp
-
Fired after clicking on a cell or row/column header. In case the row/column header was clicked, the coordinate
indexes are negative.For example clicking on the row header of cell (0, 0) results with
afterOnCellMouseUpcalled
with coordinates{row: 0, col: -1}.Parameters:
Name Type Description eventEvent mouseupevent object.coordsCellCoords Coordinates object containing the visual row and visual column indexes of the clicked cell.
TDHTMLTableCellElement Cell's TD (or TH) element.
-
afterPaste
-
Fired by
CopyPasteplugin after values are pasted into table. This hook is fired when
Options#copyPasteoption is enabled.Parameters:
Name Type Description dataArray.<Array> An array of arrays which contains the pasted data.
coordsArray.<Object> An array of objects with ranges of the visual indexes (
startRow,startCol,endRow,endCol)
that correspond to the previously selected area. -
afterPluginsInitialized
-
Fired after initializing all the plugins.
-
afterRedo
-
Fired by
UndoRedoplugin after the redo action. Contains information about the action that is being redone.
This hook is fired whenOptions#undooption is enabled.Parameters:
Name Type Description actionObject The action object. Contains information about the action being redone. The
actionType
property of the object specifies the type of the action in a String format (e.g.'remove_row'). -
afterRemoveCellMeta
-
Fired after cell meta is removed.
Parameters:
Name Type Description rowNumber Visual row index.
columnNumber Visual column index.
keyString The removed meta key.
value* Value which was under removed key of cell meta.
-
afterRemoveCol
-
Fired after one or more columns are removed.
Parameters:
Name Type Description indexNumber Visual index of starter column.
amountNumber An amount of removed columns.
physicalColumnsArray.<Number> An array of physical columns removed from the data source.
sourceString optional String that identifies source of hook call (list of all available sources).
-
afterRemoveRow
-
Fired after one or more rows are removed.
Parameters:
Name Type Description indexNumber Visual index of starter row.
amountNumber An amount of removed rows.
physicalRowsArray.<Number> An array of physical rows removed from the data source.
sourceString optional String that identifies source of hook call (list of all available sources).
-
afterRender
-
Fired after the Handsontable table is rendered.
Parameters:
Name Type Description isForcedBoolean Is
trueif rendering was triggered by a change of settings or data; orfalseif
rendering was triggered by scrolling or moving selection. -
afterRenderer
-
Fired after finishing rendering the cell (after the renderer finishes).
Parameters:
Name Type Description TDHTMLTableCellElement Currently rendered cell's TD element.
rowNumber Visual row index.
columnNumber Visual column index.
propString | Number Column property name or a column index, if datasource is an array of arrays.
value* Value of the rendered cell.
cellPropertiesObject Object containing the cell's properties.
-
afterRowMove
-
Fired by
ManualRowMoveplugin after change order of the visual indexes. This hook is fired when
Options#manualRowMoveoption is enabled.Parameters:
Name Type Description rowsArray.<Number> An array of visual row indexes that were moved.
targetNumber Visual row index being a target for moved rows.
-
afterRowResize
-
Fired by
ManualRowResizeplugin after rendering the table with modified row sizes. This hook is
fired whenOptions#manualRowResizeoption is enabled.Parameters:
Name Type Description currentRowNumber Visual index of the resized row.
newSizeNumber Calculated new row height.
isDoubleClickBoolean Flag that determines whether there was a double-click.
-
afterScrollHorizontally
-
Fired after the horizontal scroll event.
-
afterScrollVertically
-
Fired after the vertical scroll event.
-
afterSelection
-
Fired after one or more cells are selected (e.g. during mouse move).
Parameters:
Name Type Description rowNumber Selection start visual row index.
columnNumber Selection start visual column index.
row2Number Selection end visual row index.
column2Number Selection end visual column index.
preventScrollingObject Object with
valueproperty where its value change will be observed.selectionLayerLevelNumber The number which indicates what selection layer is currently modified.
Example
new Handsontable(element, { afterSelection: (row, column, row2, column2, preventScrolling, selectionLayerLevel) => { // setting if prevent scrolling after selection preventScrolling.value = true; } }) -
afterSelectionByProp
-
Fired after one or more cells are selected.
The
propandprop2arguments represent the source object property name instead of the column number.Parameters:
Name Type Description rowNumber Selection start visual row index.
propString Selection start data source object property name.
row2Number Selection end visual row index.
prop2String Selection end data source object property name.
preventScrollingObject Object with
valueproperty where its value change will be observed.selectionLayerLevelNumber The number which indicates what selection layer is currently modified.
Example
new Handsontable(element, { afterSelectionByProp: (row, column, row2, column2, preventScrolling, selectionLayerLevel) => { // setting if prevent scrolling after selection preventScrolling.value = true; } }) -
afterSelectionEnd
-
Fired after one or more cells are selected (e.g. on mouse up).
Parameters:
Name Type Description rowNumber Selection start visual row index.
columnNumber Selection start visual column index.
row2Number Selection end visual row index.
column2Number Selection end visual column index.
selectionLayerLevelNumber The number which indicates what selection layer is currently modified.
-
afterSelectionEndByProp
-
Fired after one or more cells are selected (e.g. on mouse up).
The
propandprop2arguments represent the source object property name instead of the column number.Parameters:
Name Type Description rowNumber Selection start visual row index.
propString Selection start data source object property index.
row2Number Selection end visual row index.
prop2String Selection end data source object property index.
selectionLayerLevelNumber The number which indicates what selection layer is currently modified.
-
afterSetCellMeta
-
Fired after cell meta is changed.
Parameters:
Name Type Description rowNumber Visual row index.
columnNumber Visual column index.
keyString The updated meta key.
value* The updated meta value.
-
afterSetDataAtCell
-
Fired after cell data was changed.
Parameters:
Name Type Description changesArray An array of changes in format
[[row, column, oldValue, value], ...].sourceString optional String that identifies source of hook call
(list of all available sources). -
afterSetDataAtRowProp
-
Fired after cell data was changed.
Parameters:
Name Type Description changesArray An array of changes in format
[[row, prop, oldValue, value], ...].sourceString optional String that identifies source of hook call
(list of all available sources). -
afterTrimRow
-
Fired by
TrimRowsplugin after trimming rows. This hook is fired whenOptions#trimRowsoption is enabled.Parameters:
Name Type Description rowsArray.<Number> Physical indexes of trimmed rows.
-
afterUndo
-
Fired by
UndoRedoplugin after the undo action. Contains information about the action that is being undone.
This hook is fired whenOptions#undooption is enabled.Parameters:
Name Type Description actionObject The action object. Contains information about the action being undone. The
actionType
property of the object specifies the type of the action in a String format. (e.g.'remove_row'). -
afterUnlisten
-
Fired after the table was switched off from the listening mode. This makes the Handsontable inert for any
keyboard events. -
afterUnmergeCells
-
Fired by
MergeCellsplugin after unmerging the cells. This hook is fired whenOptions#mergeCells
option is enabled.Parameters:
Name Type Default Description cellRangeCellRange Selection cell range.
autoBoolean false optional trueif called automatically by the plugin. -
afterUntrimRow
-
Fired by
TrimRowsplugin after untrimming rows. This hook is fired whenOptions#trimRowsoption is enabled.Parameters:
Name Type Description rowsArray.<Number> Physical indexes of untrimmed rows.
-
afterUpdateSettings
-
Fired after calling the
updateSettingsmethod.Parameters:
Name Type Description newSettingsObject New settings object.
-
afterValidate
-
A plugin hook executed after validator function, only if validator function is defined.
Validation result is the first parameter. This can be used to determinate if validation passed successfully or not.Returning false from the callback will mark the cell as invalid.
Parameters:
Name Type Description isValidBoolean trueif valid,falseif not.value* The value in question.
rowNumber Visual row index.
propString | Number Property name / visual column index.
sourceString optional String that identifies source of hook call
(list of all available sources). -
afterViewportColumnCalculatorOverride
-
Fired inside the
viewportColumnCalculatorOverridemethod. Allows modifying the row calculator parameters.Parameters:
Name Type Description calcObject The row calculator.
-
afterViewportRowCalculatorOverride
-
Fired inside the
viewportRowCalculatorOverridemethod. Allows modifying the row calculator parameters.Parameters:
Name Type Description calcObject The row calculator.
-
beforeAddChild
-
Fired by
NestedRowsplugin before adding a children to the NestedRows structure. This hook is fired when
Options#nestedRowsoption is enabled.Parameters:
Name Type Description parentObject The parent object.
elementObject | undefined The element added as a child. If
undefined, a blank child was added.indexNumber | undefined The index within the parent where the new child was added. If
undefined, the element was added as the last child. -
beforeAutofill
-
Fired by
Autofillplugin before populating the data in the autofill feature. This hook is fired when
Options#fillHandleoption is enabled.Parameters:
Name Type Description startCellCoords Object containing information about first filled cell:
{row: 2, col: 0}.endCellCoords Object containing information about last filled cell:
{row: 4, col: 1}.dataArray.<Array> 2D array containing information about fill pattern:
[["1", "Ted"], ["1", "John"]]. -
beforeAutofillInsidePopulate
-
Fired from the
populateFromArraymethod during theautofillprocess. Fired for each "autofilled" cell individually.Parameters:
Name Type Description indexObject Object containing
rowandcolproperties, defining the number of rows/columns from the initial cell of the autofill.directionString Declares the direction of the autofill. Possible values:
up,down,left,right.inputArray.<Array> Contains an array of rows with data being used in the autofill.
deltasArray The deltas array passed to the
populateFromArraymethod. -
beforeCellAlignment
-
Fired before aligning the cell contents.
Parameters:
Name Type Description stateBeforeObject An object with class names defining the cell alignment.
rangeArray.<CellRange> An array of CellRange coordinates where the alignment will be applied.
typeString Type of the alignment - either
horizontalorvertical.alignmentClassString String defining the alignment class added to the cell.
Possible values:htLefthtCenterhtRighthtJustifyhtTophtMiddlehtBottom
-
beforeChange
-
Fired before one or more cells is changed. Its main purpose is to alter changes silently after input and before
table rendering.Parameters:
Name Type Description changesArray.<Array> 2D array containing information about each of the edited cells.
sourceString optional String that identifies source of hook call
(list of all available sources).Example
// To disregard a single change, set changes[i] to null or remove it from array using changes.splice(i, 1). new Handsontable(element, { beforeChange: (changes, source) => { // [[row, prop, oldVal, newVal], ...] changes[0] = null; } }); // To alter a single change, overwrite the desired value to changes[i][3]. new Handsontable(element, { beforeChange: (changes, source) => { // [[row, prop, oldVal, newVal], ...] changes[0][3] = 10; } }); // To cancel all edit, return false from the callback or set array length to 0 (changes.length = 0). new Handsontable(element, { beforeChange: (changes, source) => { // [[row, prop, oldVal, newVal], ...] return false; } }); -
beforeChangeRender
-
Fired right before rendering the changes.
Parameters:
Name Type Description changesArray.<Array> Array in form of
[row, prop, oldValue, newValue].sourceString optional String that identifies source of hook call
(list of all available sources). -
beforeColumnMove
-
Fired by
ManualColumnMoveplugin before change order of the visual indexes. This hook is fired when
Options#manualColumnMoveoption is enabled.Parameters:
Name Type Description columnsArray.<Number> Array of visual column indexes to be moved.
targetNumber Visual column index being a target for moved columns.
-
beforeColumnResize
-
Fired by
ManualColumnResizeplugin before rendering the table with modified column sizes. This hook is
fired whenOptions#manualColumnResizeoption is enabled.Parameters:
Name Type Description currentColumnNumber Visual index of the resized column.
newSizeNumber Calculated new column width.
isDoubleClickBoolean Flag that determines whether there was a double-click.
Returns: {Number} Returns a new column size or
undefined, if column size should be calculated automatically. -
beforeColumnSort
-
Fired by
ColumnSortingandMultiColumnSortingplugins before sorting the column. If you returnfalsevalue inside callback for hook, then sorting
will be not applied by the Handsontable (useful for server-side sorting).This hook is fired when
Options#columnSortingorOptions#multiColumnSortingoption is enabled.Parameters:
Name Type Description currentSortConfigArray Current sort configuration (for all sorted columns).
destinationSortConfigsArray Destination sort configuration (for all sorted columns).
-
beforeContextMenuSetItems
-
Fired by
ContextMenuplugin before setting up the Context Menu's items but after filtering these options by
user (contextMenuoption). This hook can by helpful to determine if user use specified menu item or to set up
one of the menu item to by always visible.Parameters:
Name Type Description menuItemsArray.<Object> An array of objects containing information about to generated Context Menu items.
-
beforeContextMenuShow
-
Fired by
ContextMenuplugin before opening the Context Menu. This hook is fired whenOptions#contextMenu
option is enabled.Parameters:
Name Type Description contextObject The Context Menu instance.
-
beforeCopy
-
Fired before values are copied into clipboard.
Parameters:
Name Type Description dataArray.<Array> An array of arrays which contains data to copied.
coordsArray.<Object> An array of objects with ranges of the visual indexes (
startRow,startCol,endRow,endCol)
which will copied.Returns: {*} If returns
falsethen copying is canceled.Example
// To disregard a single row, remove it from array using data.splice(i, 1). ... new Handsontable(document.getElementById('example'), { beforeCopy: (data, coords) => { // data -> [[1, 2, 3], [4, 5, 6]] data.splice(0, 1); // data -> [[4, 5, 6]] // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}] } }); ... // To cancel copying, return false from the callback. ... new Handsontable(document.getElementById('example'), { beforeCopy: (data, coords) => { return false; } }); ... -
beforeCreateCol
-
Fired before created a new column.
Parameters:
Name Type Description indexNumber Represents the visual index of first newly created column in the data source array.
amountNumber Number of newly created columns in the data source array.
sourceString optional String that identifies source of hook call
(list of all available sources). -
beforeCreateRow
-
Fired before created a new row.
Parameters:
Name Type Description indexNumber Represents the visual index of first newly created row in the data source array.
amountNumber Number of newly created rows in the data source array.
sourceString optional String that identifies source of hook call
(list of all available sources). -
beforeCut
-
Fired by
CopyPasteplugin before copying the values into clipboard and before clearing values of
the selected cells. This hook is fired whenOptions#copyPasteoption is enabled.Parameters:
Name Type Description dataArray.<Array> An array of arrays which contains data to cut.
coordsArray.<Object> An array of objects with ranges of the visual indexes (
startRow,startCol,endRow,endCol)
which will be cut out.Returns: {*} If returns
falsethen operation of the cutting out is canceled.Example
// To disregard a single row, remove it from the array using data.splice(i, 1). new Handsontable(element, { beforeCut: function(data, coords) { // data -> [[1, 2, 3], [4, 5, 6]] data.splice(0, 1); // data -> [[4, 5, 6]] // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}] } }); // To cancel a cutting action, just return `false`. new Handsontable(element, { beforeCut: function(data, coords) { return false; } }); -
beforeDetachChild
-
Fired by
NestedRowsplugin before detaching a child from its parent. This hook is fired when
Options#nestedRowsoption is enabled.Parameters:
Name Type Description parentObject An object representing the parent from which the element is to be detached.
elementObject The detached element.
-
beforeDrawBorders
-
Fired before drawing the borders.
Parameters:
Name Type Description cornersArray Array specifying the current selection borders.
borderClassNameString Specifies the border class name.
-
beforeDropdownMenuSetItems
-
Fired by
DropdownMenuplugin before setting up the Dropdown Menu's items but after filtering these options
by user (dropdownMenuoption). This hook can by helpful to determine if user use specified menu item or to set
up one of the menu item to by always visible.Parameters:
Name Type Description menuItemsArray.<Object> An array of objects containing information about to generated Dropdown Menu items.
-
beforeDropdownMenuShow
-
Fired by
DropdownMenuplugin before opening the dropdown menu. This hook is fired whenOptions#dropdownMenu
option is enabled.Parameters:
Name Type Description dropdownMenuDropdownMenu The DropdownMenu instance.
-
beforeFilter
-
Fired by
Filtersplugin before applying filtering. This hook is fired when
Options#filtersoption is enabled.Parameters:
Name Type Description conditionsStackArray.<Object> An array of objects with added formulas.
// Example format of the conditionsStack argument: [ { column: 2, conditions: [ {name: 'begins_with', args: [['S']]} ], operation: 'conjunction' }, { column: 4, conditions: [ {name: 'not_empty', args: []} ], operation: 'conjunction' }, ]Returns: {Boolean} If hook returns
falsevalue then filtering won't be applied on the UI side (server-side filtering). -
beforeGetCellMeta
-
Fired before getting cell settings.
Parameters:
Name Type Description rowNumber Visual row index.
columnNumber Visual column index.
cellPropertiesObject Object containing the cell's properties.
-
beforeInit
-
Fired before the Handsontable instance is initiated.
-
beforeInitWalkontable
-
Fired before the Walkontable instance is initiated.
Parameters:
Name Type Description walkontableConfigObject Walkontable configuration object.
-
beforeKeyDown
-
Fired before keydown event is handled. It can be used to overwrite default key bindings.
Note: To prevent default behavior you need to call
event.stopImmediatePropagation()in yourbeforeKeyDown
handler.Parameters:
Name Type Description eventEvent Original DOM event.
-
beforeLanguageChange
-
Fired before successful change of language (when proper language code was set)
Parameters:
Name Type Description languageCodeString New language code.
- Since: 0.35.0
-
beforeMergeCells
-
Fired by
MergeCellsplugin before cell merging. This hook is fired whenOptions#mergeCells
option is enabled.Parameters:
Name Type Default Description cellRangeCellRange Selection cell range.
autoBoolean false optional trueif called automatically by the plugin. -
beforeOnCellContextMenu
-
Fired after the user clicked a cell, but before all the calculations related with it.
Parameters:
Name Type Description eventEvent The
contextmenuevent object.coordsCellCoords Cell coords object containing the visual coordinates of the clicked cell.
TDHTMLTableCellElement TD element.
- Since: 4.1.0
-
beforeOnCellMouseDown
-
Fired after the user clicked a cell, but before all the calculations related with it.
Parameters:
Name Type Description eventEvent The
mousedownevent object.coordsCellCoords Cell coords object containing the visual coordinates of the clicked cell.
TDHTMLTableCellElement TD element.
controllerObject An object with keys
row,columnandcellswhich contains boolean values. This
object allows or disallows changing the selection for the particular axies. -
beforeOnCellMouseOut
-
Fired after the user moved cursor out from a cell, but before all the calculations related with it.
Parameters:
Name Type Description eventEvent The
mouseoutevent object.coordsCellCoords CellCoords object containing the visual coordinates of the leaved cell.
TDHTMLTableCellElement TD element.
-
beforeOnCellMouseOver
-
Fired after the user moved cursor over a cell, but before all the calculations related with it.
Parameters:
Name Type Description eventEvent The
mouseoverevent object.coordsCellCoords CellCoords object containing the visual coordinates of the clicked cell.
TDHTMLTableCellElement TD element.
controllerObject An object with keys
row,columnandcellswhich contains boolean values. This
object allows or disallows changing the selection for the particular axies. -
beforeOnCellMouseUp
-
Fired after the user clicked a cell.
Parameters:
Name Type Description eventEvent The
mouseupevent object.coordsCellCoords Cell coords object containing the visual coordinates of the clicked cell.
TDHTMLTableCellElement TD element.
controllerObject An object with keys
row,columnandcellswhich contains boolean values. This
object allows or disallows changing the selection for the particular axies. -
beforePaste
-
Fired by
CopyPasteplugin before values are pasted into table. This hook is fired when
Options#copyPasteoption is enabled.Parameters:
Name Type Description dataArray.<Array> An array of arrays which contains data to paste.
coordsArray.<Object> An array of objects with ranges of the visual indexes (
startRow,startCol,endRow,endCol)
that correspond to the previously selected area.Returns: {*} If returns
falsethen pasting is canceled.Example
// To disregard a single row, remove it from array using data.splice(i, 1). new Handsontable(example, { beforePaste: (data, coords) => { // data -> [[1, 2, 3], [4, 5, 6]] data.splice(0, 1); // data -> [[4, 5, 6]] // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}] } }); // To cancel pasting, return false from the callback. new Handsontable(example, { beforePaste: (data, coords) => { return false; } }); -
beforeRedo
-
Fired by
UndoRedoplugin before the redo action. Contains information about the action that is being redone.
This hook is fired whenOptions#undooption is enabled.Parameters:
Name Type Description actionObject The action object. Contains information about the action being redone. The
actionType
property of the object specifies the type of the action in a String format (e.g.'remove_row'). -
beforeRemoveCellClassNames
-
Fired inside the Walkontable's
refreshSelectionsmethod. Can be used to remove additional class names from all cells in the table.- Since: 0.38.1
Returns: {Array.<String>|undefined} Can return an
ArrayofStrings. Each of these strings will act like class names to be removed from all the cells in the table. -
beforeRemoveCellMeta
-
Fired before cell meta is removed.
Parameters:
Name Type Description rowNumber Visual row index.
columnNumber Visual column index.
keyString The removed meta key.
value* Value which is under removed key of cell meta.
-
beforeRemoveCol
-
Fired before one or more columns are about to be removed.
Parameters:
Name Type Description indexNumber Visual index of starter column.
amountNumber Amount of columns to be removed.
physicalColumnsArray.<Number> An array of physical columns removed from the data source.
sourceString optional String that identifies source of hook call (list of all available sources).
-
beforeRemoveRow
-
Fired when one or more rows are about to be removed.
Parameters:
Name Type Description indexNumber Visual index of starter column.
amountNumber Amount of columns to be removed.
physicalRowsArray.<Number> An array of physical rows removed from the data source.
sourceString optional String that identifies source of hook call (list of all available sources).
-
beforeRender
-
Fired before the Handsontable table is rendered.
Parameters:
Name Type Description isForcedBoolean If
truerendering was triggered by a change of settings or data; orfalseif
rendering was triggered by scrolling or moving selection. -
beforeRenderer
-
Fired before starting rendering the cell.
Parameters:
Name Type Description TDHTMLTableCellElement Currently rendered cell's TD element.
rowNumber Visual row index.
columnNumber Visual column index.
propString | Number Column property name or a column index, if datasource is an array of arrays.
value* Value of the rendered cell.
cellPropertiesObject Object containing the cell's properties.
-
beforeRowMove
-
Fired by
ManualRowMoveplugin before change order of the visual indexes. This hook is fired when
Options#manualRowMoveoption is enabled.Parameters:
Name Type Description rowsArray.<Number> An array of visual row indexes to be moved.
targetNumber Visual row index being a target for moved rows.
-
beforeRowResize
-
Fired by
ManualRowResizeplugin before rendering the table with modified row sizes. This hook is
fired whenOptions#manualRowResizeoption is enabled.Parameters:
Name Type Description currentRowNumber Visual index of the resized row.
newSizeNumber Calculated new row height.
isDoubleClickBoolean Flag that determines whether there was a double-click.
Returns: {Number} Returns the new row size or
undefinedif row size should be calculated automatically. -
beforeSetRangeEnd
-
Fired before setting range is ended.
Parameters:
Name Type Description coordsCellCoords CellCoords instance.
-
beforeSetRangeStart
-
Fired before setting range is started.
Parameters:
Name Type Description coordsCellCoords CellCoords instance.
-
beforeSetRangeStartOnly
-
Fired before setting range is started but not finished yet.
Parameters:
Name Type Description coordsCellCoords CellCoords instance.
-
beforeStretchingColumnWidth
-
Fired before applying stretched column width to column.
Parameters:
Name Type Description stretchedWidthNumber Calculated width.
columnNumber Visual column index.
Returns: {Number} Returns new width which will be applied to the column element.
-
beforeTouchScroll
-
Fired before the logic of handling a touch scroll, when user started scrolling on a touch-enabled device.
-
beforeUndo
-
Fired by
UndoRedoplugin before the undo action. Contains information about the action that is being undone.
This hook is fired whenOptions#undooption is enabled.Parameters:
Name Type Description actionObject The action object. Contains information about the action being undone. The
actionType
property of the object specifies the type of the action in a String format. (e.g.'remove_row'). -
beforeUnmergeCells
-
Fired by
MergeCellsplugin before unmerging the cells. This hook is fired whenOptions#mergeCells
option is enabled.Parameters:
Name Type Default Description cellRangeCellRange Selection cell range.
autoBoolean false optional trueif called automatically by the plugin. -
beforeValidate
-
Fired before cell validation, only if validator function is defined. This can be used to manipulate the value
of changed cell before it is applied to the validator function.Note: this will not affect values of changes. This will change value ONLY for validation
Parameters:
Name Type Description value* Value of the cell.
rowNumber Visual row index.
propString | Number Property name / column index.
sourceString optional String that identifies source of hook call
(list of all available sources). -
beforeValueRender
-
Fired before cell value is rendered into the DOM (through renderer function). This can be used to manipulate the
value which is passed to the renderer without modifying the renderer itself.Parameters:
Name Type Description value* Cell value to render.
cellPropertiesObject An object containing the cell properties.
-
construct
-
Fired after Handsontable instance is constructed (using
newoperator). -
hiddenColumn
-
Fired by
HiddenColumnsplugin to check whether the provided column index is hidden. This hook is fired when
Options#hiddenColumnsoption is enabled.Parameters:
Name Type Description columnNumber The visual column index in question.
-
hiddenRow
-
Fired by
HiddenRowsplugin to check whether the provided row index is hidden. This hook is fired when
Options#hiddenRowsoption is enabled.Parameters:
Name Type Description rowNumber The visual row index in question.
-
init
-
Fired after Handsontable instance is initiated but before table is rendered.
-
modifyAutofillRange
-
Fired by
Autofillplugin after setting range of autofill. This hook is fired whenOptions#fillHandle
option is enabled.Parameters:
Name Type Description startAreaArray Array of visual coordinates of the starting point for the drag-down operation (
[startRow, startColumn, endRow, endColumn]).entireAreaArray Array of visual coordinates of the entire area of the drag-down operation (
[startRow, startColumn, endRow, endColumn]). -
modifyCol
-
Fired when a column index is about to be modified by a callback function.
Parameters:
Name Type Description columnNumber Visual column index.
-
modifyColHeader
-
Fired when a column header index is about to be modified by a callback function.
Parameters:
Name Type Description columnNumber Visual column header index.
-
modifyColumnHeaderHeight
-
Fired while retrieving the column header height.
-
modifyColWidth
-
Fired when a column width is about to be modified by a callback function.
Parameters:
Name Type Description widthNumber Current column width.
columnNumber Visual column index.
-
modifyCopyableRange
-
Fired to allow modifying the copyable range with a callback function.
Parameters:
Name Type Description copyableRangesArray.<Array> Array of objects defining copyable cells.
-
modifyData
-
Fired when a data was retrieved or modified.
Parameters:
Name Type Description rowNumber Row height.
columnNumber Column index.
valueHolderObject Object which contains original value which can be modified by overwriting
.valueproperty.ioModeString String which indicates for what operation hook is fired (
getorset). -
modifyGetCellCoords
-
Used to modify the cell coordinates when using the
getCellmethod.Parameters:
Name Type Description rowNumber Visual row index.
columnNumber Visual column index.
topmostBoolean If set to
true, it returns the TD element from the topmost overlay. For example,
if the wanted cell is in the range of fixed rows, it will return a TD element
from thetopoverlay.- Since: 0.36.0
-
modifyRow
-
Fired when a row index is about to be modified by a callback function.
Parameters:
Name Type Description rowNumber Visual row index.
-
modifyRowData
-
Fired when a data was retrieved or modified.
Parameters:
Name Type Description rowNumber Physical row index.
-
modifyRowHeader
-
Fired when a row header index is about to be modified by a callback function.
Parameters:
Name Type Description rowNumber Visual row header index.
-
modifyRowHeaderWidth
-
Fired while retrieving the row header width.
Parameters:
Name Type Description rowHeaderWidthNumber Row header width.
-
modifyRowHeight
-
Fired when a row height is about to be modified by a callback function.
Parameters:
Name Type Description heightNumber Row height.
rowNumber Visual row index.
-
modifyTransformEnd
-
Fired when the end of the selection is being modified (e.g. moving the selection with the arrow keys).
Parameters:
Name Type Description deltaCellCoords Cell coords object declaring the delta of the new selection relative to the previous one.
-
modifyTransformStart
-
Fired when the start of the selection is being modified (e.g. moving the selection with the arrow keys).
Parameters:
Name Type Description deltaCellCoords Cell coords object declaring the delta of the new selection relative to the previous one.
-
persistentStateLoad
-
Fired by
PersistentStateplugin, after loading value, saved under given key, from browser local storage. This hook is fired when
Options#persistentStateoption is enabled.Parameters:
Name Type Description keyString Key.
valuePlaceholderObject Object containing the loaded value under
valuePlaceholder.value(if no value have been saved,valuekey will be undefined). -
persistentStateReset
-
Fired by
PersistentStateplugin after resetting data from local storage. If no key is given, all values associated with table will be cleared.
This hook is fired whenOptions#persistentStateoption is enabled.Parameters:
Name Type Description keyString optional Key.
-
persistentStateSave
-
Fired by
PersistentStateplugin, after saving value under given key in browser local storage. This hook is fired when
Options#persistentStateoption is enabled.Parameters:
Name Type Description keyString Key.
valueMixed Value to save.
-
skipLengthCache
-
Used to skip the length cache calculation for a defined period of time.
Parameters:
Name Type Description delayNumber The delay in milliseconds.
-
unmodifyCol
-
Fired when a column index is about to be de-modified by a callback function.
Parameters:
Name Type Description columnNumber Physical column index.
-
unmodifyRow
-
Fired when a physical row index is about to be de-modified by a callback function.
Parameters:
Name Type Description rowNumber Physical row index.