Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by swats on Mar 25, 2008 06:39
open dhtmlx forum
Unable to set the value of a cell in dhtmlxgrid

Hi..

I m facing an issue in setting the value of a cell.On edit of a cell i m calling a function which is here :

function doOnCellEdit(stage,rowId,cellInd){

    if(stage==0){
         return true;
        }else if(stage==1){
            
        }else if(stage==2){
            alert(mygrid.cells(mygrid.getSelectedId(), mygrid.getSelectedCellIndex()).getValue());
mygrid.cells(rowId,cellInd).setValue(mygrid.cells(mygrid.getSelectedId(), mygrid.getSelectedCellIndex()).getValue());


        }
    }

But when i m pointing to another row , the edited cell value reverts back to the previous value.


Kindly help me in this issue.

Thanks in advance
Answer posted by Support on Mar 25, 2008 08:51
The return value of onEditCell event is matter

return true; - confirm edit operation
return false; or not return anything - block edit operation
In your case nothing returned, so its treated as blocking, and cell reverted to previous value

So to correct code, just modify it in the next way


function doOnCellEdit(stage,rowId,cellInd){

    if(stage==0){
         return true;
        }else if(stage==1){
            
        }else if(stage==2){
            mygrid.cells(rowId,cellInd).setValue(mygrid.cells(mygrid.getSelectedId(), mygrid.getSelectedCellIndex()).getValue());
            return true;
        }
    }