Skip to main content

Actions overview

This section is dedicated to a new conception of interaction with Spreadsheet events.

Starting from v4.3, DHTMLX Spreadsheet includes a pair of the beforeAction/afterAction events that are intended to make your code simple and concise. They will fire right before an action is executed and indicate which exactly action has been performed.

spreadsheet.events.on("beforeAction", (actionName, config) => {
if (actionName === "addColumn") {
console.log(actionName, config);
return false;
},
// more actions
});

spreadsheet.events.on("afterAction", (actionName, config) => {
if (actionName === "addColumn") {
console.log(actionName, config)
},
// more actions
});

The full list of the available actions is given below.

It means, that you don't have to constantly add sets of paired before- and after- events anymore to track and handle the actions which you execute when changing something in the spreadsheet.

But if needed you can use an old approach because all the existing events will continue work as before:

spreadsheet.events.on("afterColumnAdd", function(cell){
console.log("A new column is added", cell);
});
spreadsheet.events.on("beforeColumnAdd", function(cell){
console.log("A new column will be added", cell);
return true;
});

List of actions

ActionDescription
addColumnThe action is executed when adding a new column
addRowThe action is executed when adding a new row
addSheetThe action is executed when adding a new sheet
clearThe action is executed when clearing the spreadsheet via the clear() method
clearSheetThe action is executed when clearing a sheet via the clearSheet() method
deleteColumnThe action is executed when removing a column
deleteRowThe action is executed when removing a row
deleteSheetThe action is executed when removing a sheet
filterThe action is executed when filtering data in a sheet
fitColumnThe action is executed when auto-fitting the width of the column
groupActionThe action is executed when selecting a range of cells and applying to them some actions (for instance, change the style or format of cells, lock/unlock the cells, clear cells' value or styles, etc.)
insertLinkThe action is executed when inserting a hyperlink in a cell
lockCellThe action is executed when locking/unlocking a cell
mergeThe action is executed when merging a range of cells
removeCellStylesThe action is executed when clearing styles of a cell
renameSheetThe action is executed when renaming a sheet
resizeColThe action is executed when resizing a column
resizeRowThe action is executed when resizing a row
setCellFormatThe action is executed when changing the format of a cell
setCellValueThe action is executed when changing or removing the value of a cell
setValidationThe action is executed when setting data validation for a cell
sortCellsThe action is executed when sorting data in spreadsheet
setCellStyleThe action is executed when changing the style of a cell
unmergeThe action is executed when splitting cells

Change log:

  • The merge, unmerge, filter, fitColumn, insertLink actions were added in v5.0

Related sample: Spreadsheet. Actions