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 you add a new column
addRowThe action is executed when you add a new row
addSheetThe action is executed when you add a new sheet
clearThe action is executed when you clear the spreadsheet via the clear() method
clearSheetThe action is executed when you clear a sheet via the clearSheet() method
deleteColumnThe action is executed when you remove a column
deleteRowThe action is executed when you remove a row
deleteSheetThe action is executed when you remove a sheet
groupActionThe action is executed when you select a range of cells and apply to them some actions (for instance, change the style or format of cells, lock/unlock the cells, clear cells' value or styles, etc.)
lockCellThe action is executed when you lock/unlock a cell
removeCellStylesThe action is executed when you clear styles of a cell
renameSheetThe action is executed when you rename a sheet
resizeColThe action is executed when you resize a column
resizeRowThe action is executed when you resize a row
setCellFormatThe action is executed when you change the format of a cell
setCellValueThe action is executed when you change or remove the value of a cell
setValidationThe action is executed when you set data validation for a cell
sortCellsThe action is executed when you sort data in spreadsheet
setCellStyleThe action is executed when you change the style of a cell

Related sample: Spreadsheet. Actions