Hi support,
Does your grid support any feature / API using which I can achieve an Undo and ReDo operation on the grid table? Or should I create it?
regards
Kelly
Starting from version 1.3 it is supported in pro edition.
Just include dhtmlxGrid_undo.js
mygrid.enableUndoRedo(true);
…
mygrid.doUndo();
…
mygrid.doRedo();
please check
samples/pro_undo.html
Just a quick follow up:
As I can see in my first test this does not trigger automatically the onCellEdit event handler (mark row updated and send update to server)
Is there any way to make this happen in the same moment the user hits the undo button ?
To reproduce this :
Modify a row, hit Undo, and then refresh page. The page shows the row modified (So undo did the work but didn’t save)
Yes, the undo|redo doesn’t trigger the events ( probably this can be counted as a bug, and fixed in next version ), for now in case of dataprocessor usage, you can manually triger DB saving by executing
myDataProcessor.setUpdated(id,true)
where id - id of row in which cell was changed
to automate such update you can insert such line directly in dhtmlxGrid_undo.js,
dhtmlXGridObject.prototype.doUndo = function()
{
if (this._UndoRedoPos === -1)
return false;
var obj = this._UndoRedoData[this._UndoRedoPos–];
this.cells(obj.row_id, obj.cell_index).setValue(obj.old_value);
myDataProcessor.setUpdated(obj.row_id,true)
}
Many thanks for the Answer.
If I implement this I will write a custom function and paste it here.
Hello, I have the same problem with the OnCellEdit event handler that isn’t triggered automatically after undo/redo…
How can the events be triggered without the usage of the dataprocessor?
onCellEdit event generated only for cases when cell changed by user actions, such event not generated for any API calls, but it can be updated in the way similar to described above, just update code
dhtmlXGridObject.prototype.doUndo = function()
{
if (this._UndoRedoPos === -1)
return false;
var obj = this._UndoRedoData[this._UndoRedoPos–];
this.cells(obj.row_id, obj.cell_index).setValue(obj.old_value);
this.callEvent(“onCellEdit”,[2,obj.row_id,obj.cell_index]);
}
Thanks for your answer, it works perfectly.
Just one short remark: the event is called “OnEditCell” and not “OnCellEdit”.