getHistory()
pro version only
This functionality requires PRO version of the DHTMLX Grid (or DHTMLX Suite) package.
returns a copy of the array of all actions in the Grid history to prevent accidental modification of the internal structure
Usage
type ActionType = "add" | "remove" | "removeAll" | "change";
interface IAction {
type: ActionType;
batch: IRow[];
inverse?: IAction;
}
getHistory(): IAction[];
Returns:
Returns a copy of the array of all actions in the Grid history, where each action presents an object described below:
action | (object) the action object that contains the following properties:
|
Example
// The example shows retrieving the history
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
});
// adding actions
grid.history.add({
type: "change",
batch: [{ id: "1", name: "Updated Item", value: 15 }],
inverse: { type: "change", batch: [{ id: "1", name: "Item 1", value: 10 }] },
});
grid.history.add({
type: "add",
batch: [{ id: "2", name: "New Item", value: 20 }],
});
// retrieving the history
const history = grid.history.getHistory();
console.log(history.length); // -> 2
Related article: Getting the history of Grid actions
Related API: add()
, remove()
, removeAll()
Change log:
added in v9.2