Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on May 22, 2007 12:39
open dhtmlx forum
Undo & Redo functions on SCAND Grid

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
Answer posted on May 22, 2007 13:37
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
Answer posted by Martin F. on Jun 29, 2007 14:37
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)
Answer posted on Jul 04, 2007 12:06
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)    
}
Answer posted by Martin F. on Jul 05, 2007 09:03
Many thanks for the Answer.
If I implement this I will write a custom function and paste it here.
Answer posted by Pascal R. on Sep 24, 2007 21:36
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?
Answer posted on Sep 25, 2007 13:46
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]);
}
Answer posted by Pascal R. on Sep 26, 2007 14:15
Thanks for your answer, it works perfectly.

Just one short remark: the event is called "OnEditCell" and not "OnCellEdit".
Answer posted by radyno (Support) on Dec 09, 2014 20:46

The information connected with editable combo box in jsp and web grid control also can help you, so please check it too.