Event handlings on editing

Hi to everyone!

This is my problem: I have a datatables that shows value that are calculated: however, when I have to editing a cell in the grid:

  • when I start editing on a cell, the value that I want to edit must be different from the one that appears on the grid ( because I need to take the real value from another datasource)

  • if the value has not changed, when I change cell or close editing, the value must be set to the original calculated value

  • if the value has changed, when I close the editing box, I have to refresh data into the grid

I tried to simulate the first usecase in the snippet (http://webix.com/snippet/514959c5 ), but as you can see, I cannot come back to the original value: if you could show me how to achieve it I would appreciate a lot.

Thanks in advance ,

Faber

Hi Faber,

As for the first use case, you can get the old value from the editor state object and then cancel editing.

Note that you needn’t save old value beforehand as it can be derived from the state object.

grid.attachEvent("onBeforeEditStop", function(state, editor){
    //state {value:new_value, old:old_value}
   state.value = state.old;
   this.editCancel();
});

blockEvent and unblockEvent methods are used to temporarily prevent datatable events from firing to avoid recursion.

http://webix.com/snippet/5c546cd3