Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Richard White on Sep 27, 2007 21:26
open dhtmlx forum
OnCellEdit

Hi,

please help me set up an on cell edit event. I cannot find anything in your documentation.

We have the following code:

mygrid.setOnEditCellHandler(onCellEdit);

followed by the following function:

function onCellEdit(stage,rowId,cellId,newValue,oldValue)
    {
    
if(stage == 2)
     {
     if(newValue != oldValue)
        {
         mygrid.cells(rowId, cellId).setValue(newValue);
         }
     }
    }

do you have any ideas why this is not working?

it doesnt set the cell to the new value - it sets it to existing value (start value) - this is a coro we are using for the column type.
Answer posted by Stanislav on Sep 28, 2007 10:15
onCellEdit event occurs in moment when "editor closing", so the edit operation doesn't really finished yet, and result of making any changes in current cell in that moment is hardly predictable.
But because described situation is common use-case onCellEdit event can produce different effects based on return value

return true; //edit operation confirmed
return string; or return number; // string or number set as new cell value
return false; or not return at all // edit operation canceled, previous value restored - your case