Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Olivier on Apr 07, 2009 01:12
open dhtmlx forum
treegrid : change cell content

Hi,

I have a question about changing cells content in a treegrid.

I have a column in a treegrid which is a math calculation like this : ed[=(c9+c10+c11)/c1*1000]]

The problem is that sometime C1 = 0 so i have Infini.ty or N.aN in the cells.

I would like to have a "-" instead.

So I tried to do this :

mygrid.attachEvent("onXLE",function(id) {
mygrid.forEachRow(function(id){
if ((mygrid.cells(id,12).cell.innerHTML=='Infini.ty') || (mygrid.cells(id,12).cell.innerHTML=='N.aN'))
    mygrid.cells(id,12).cell.innerHTML='-';
if ((mygrid.cells(id,13).cell.innerHTML=='Infini.ty') || (mygrid.cells(id,12).cell.innerHTML=='N.aN'))
    mygrid.cells(id,13).cell.innerHTML='-';
    });
});


The problem is that when a row is inside a parent row, onXLE event is executed before the calculation.

How could I do ? the best way (maybe) would be to find an event after all calculation in the treegrid

Any idea?

Best regards,
Olivier
Answer posted by dhxSupport on Apr 07, 2009 01:57

You can use "onCellChanged" event:

mygrid.attachEvent("onCellChanged",function(rowId,cellIndex,newValue){
  if ((newValue=="N.aN")||(newValue=="Infini.ty"))
  mygrid.cellById(rowId,cellIndex).setValue("-");
  });


Answer posted by Olivier on Apr 07, 2009 05:46
Thank you very much  ! It works great :)