Skip to main content

beforeStyleChange

caution

The beforeStyleChange event has been deprecated in v4.3. The event will continue work, but you'd better apply a new approach:

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

For more details about the new concept, see Spreadsheet actions.

Description

Fires before the style of cells is changed

Usage

beforeStyleChange: (
cell: string,
style: string | object | array
) => void | boolean;

Parameters

The callback of the event takes the following parameters:

  • cell - (required) the id(s) of a cell(s)
  • style - (required) styles set for a cell/cells

Returns

Return true to change the style of a cell, false to prevent changing of style

Example

const spreadsheet = new dhx.Spreadsheet("spreadsheet", {});
spreadsheet.parse(data);

// subscribe on the "beforeStyleChange" event
spreadsheet.events.on("beforeStyleChange", function(cell, style){
console.log("Style of cell "+spreadsheet.selection.getSelectedCell()+" will change");
console.log(cell, style);
return true;
});

Related articles: Event handling