A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.dhtmlx.com/suite/grid/api/history/undo_method/ below:

JavaScript Grid - undo Method

Depending on the type of the action, the method either applies the inverse action (for the "change" and "removeAll" types) or restores data (for the "add" and "remove" types).

note

If the history is empty, the module is disabled, or no inverse action is available (for actions with the "change" and "removeAll" types), the error event is triggered.


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 },
{ id: "2", name: "Item 2", value: 20 },
],
history: true
});


const removedData = grid.data.serialize();
grid.data.removeAll();
grid.history.add({
type: "removeAll",
batch: [],
inverse: { type: "add", batch: removedData },
});


grid.history.undo();
console.log(grid.history.getHistory().length);
console.log(grid.history.canRedo());

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4