Undo for Data Components

While working with Webix data components, you can enable the undo functionality that allows reverting changes in case the server returns an error message.

The undo operation can be applied to any DataStore-based component.

To enable undo, you need to set the undo property to true in the configuration of the component. You can set the limit of the number of operations to revert with the help of undoLimit:

webix.ui({
    view:"list",
    id:"mylist",
    template:"#title#", 
    data:dataset,
    undo:true,
    undoLimit:40
});

The undo API includes three methods:

  • undo - reverts the previously made change in the component.
$$("mylist").undo();

Related sample:  Undo

For example, if you add an item into the component, then change it and finally decide to delete it, a call of the undo() method will revert just the result of the delete operation.

If you want to delete all the changes performed on an item and set it to the initial state, you should pass the id of this item to the undo() method.

  • removeUndo - removes history about all the operations performed on an item.
$$("mylist").removeUndo(id);

The method takes the id of an item as its parameter.

  • ignoreUndo - calls a function that will be ignored in the undo history track. The method is useful if you want the applied changes not to be reverted by the undo() method in future.
$$("mylist").ignoreUndo(function(){
    $$("mylist").addItem({...});
});

The ignoreUndo() method takes as a parameter the function for which the undo history track should be disabled.

Back to top