beforeAdd
pro version only
This functionality requires PRO version of the DHTMLX Grid (or DHTMLX Suite) package.
triggered before adding an action to the history
Usage
type ActionType = "add" | "remove" | "removeAll" | "change";
interface IAction {
type: ActionType;
batch: IRow[];
inverse?: IAction;
}
beforeAdd: (action: IAction) => boolean | void;
Parameters:
The callback of the event is called with the following parameters:
action | (object) the action object to be added that contains the following properties:
|
Returns:
Returning false
cancels the operation.
Example
const grid = new dhx.Grid("grid_container", {
columns: [
{ id: "name", header: [{ text: "Name" }] },
{ id: "value", header: [{ text: "Value" }] },
],
data: [
{ id: "1", name: "Item 1", value: 10 },
],
history: true
});
grid.history.events.on("beforeAdd", (action) => {
if (action.type === "add") {
console.log("Adding a new row is prohibited");
return false;
}
});
Related article: Adding/removing Grid history actions
Related API: add()
, afterAdd()
Change log:
added in v9.2