Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Yves on Mar 05, 2009 09:29
open dhtmlx forum
override (replace)

Hello,

If I select a value from a tree (e.g. example grid linked to tree), the value is placed into the cell. ok.

Now, I want to override this cell value with the nodeId from the selected tree node (instead of the text) and fill another cell with the text from the Node which was dblclicked.

So, I used the onDblClick event to trap both nodeId and nodeText into temporary variables.

function treeDblClick(nodeId){
    costCode=nodeId;
    costDesc=tree2.getItemText(nodeId);
    return true;
}


In the doOnCellEdit(stage,rowId,cellInd) event attached to the grid, I thought I was able to set the new values for both cells (see celInd 1 = column2). But only the first Column is changed into the new value. The second col (index 1) is filled with the selected text from the tree. So there is an event after OnCellEdit that places the text from the tree into the cell. What event would that be, and what is the best way to override this behaviour ?

function doOnCellEdit(stage,rowId,cellInd){
        if(stage==0){
            protocolIt("User starting cell editing: row id is"+rowId+", cell index is "+cellInd)
        }else if(stage==1){
            protocolIt("Cell editor opened");
            myRowId=rowId;
        }else if(stage==2){
            protocolIt("Cell editor closed");
            protocolIt(mygrid.cells(rowId,cellInd).getValue());
            if(cellInd==1) //input costCode+Desc
            {
            mygrid.cells(myRowId,0).setValue(costDesc);
            mygrid.cells(myRowId,1).setValue(costCode);
            }else if(cellInd=2)
            {
            changeExclEUR(rowId, mygrid.cells(rowId,2).getValue());
            }
        }
        return true;
}



Many thanks
Yves
Answer posted by Support on Mar 06, 2009 01:43
result of onEditCell affects the value of cell, it not possible to set final value of cell directly from event, but there is a way

  }else if(stage==2){ 
  protocolIt("Cell editor closed"); 
  protocolIt(mygrid.cells(rowId,cellInd).getValue()); 
  if(cellInd==1) //input costCode+Desc 
  { 
  mygrid.cells(myRowId,0).setValue(costDesc); 
  return costCode;

if true returned - edit operation confirmed
if false|nothing returned - edit operation blocked
any other value - will be used as new value of cell