Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Robert Oates on Sep 01, 2009 21:35
open dhtmlx forum
dhtmlxgrid refresh

Hi, I need to modify the data in a cell after the user has edited another cell of the same row, for example, user edits column 1, after edit, this new data is then placed in column 6 (of the selected row). This data is being saved to a database so the event handler shouldn't interfere with this. I understand it is along the lines of:

function doOnRowSelected(id){

modified=mygrid.cells(id,1).getValue();
mygrid.cells(id,6).setValue(modified);

}

but onrowselected isnt the correct event (i presume it is onedit, but will this interfere with the save?)

Many thanks
Rob
Answer posted by dhxSupport on Sep 02, 2009 03:02
You can use "onEditCell" event. This event occurs 1-3 times depending on cell's editability. onEditCell event passes the following parameters: 
stage - stage of editing (0-before start[can be canceled if returns false],1- the editor is opened,2- the editor is closed);
rId - id of the row;
cInd - index of the cell;
nValue - new value (only for the stage 2);
oValue - old value (only for the stage 2).
  grid.attachEvent("onEditCell", function(stage,rId,cInd,nValue,oValue){});

During normal edit process event fires 3 times 
cell edition initiated ( stage = 0 )
cell editor activated and ready for input ( stage = 1 )
cell edition finished ( stage = 2 )

The 3rd call can cause different results based on returned value 
{bool}true - confirm edit operation 
{bool}false - deny edit operation ( previous cell value will be restored ) 
{string} or {number} - provided value will be used a new value of the cell instead of one entered by user

Answer posted on Sep 02, 2009 04:45
Many thanks :)