Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Denny on Mar 23, 2009 09:17
open dhtmlx forum
Checkbox shouldn't change wasChanged

I would like to prevent a click on a checkbox (eXcell_ch) to alter the change state of its row, so that the checkbox has only a row selecting function. How can I achieve this?
Answer posted by dhxSupport on Mar 23, 2009 09:48

You can use "onCheck" event which raises after checkbox state was changed. Event contain information about rowId, cellIndex and checkbox state. 

mygrid.attachEvent("onCheck",function(rowId,cellInd,state){

if (state) mygrid.setRowColor(rowId, checked_color);

else mygrid.setRowColor(rowId, unchecked_color);

return true;

})

Answer posted by Denny on Mar 24, 2009 08:36
Thanks for your answer. However, that wasn't my question.

Imagine a grid with several rows, a checkbox column and an editable column. Now let's change the editable column in first row and let's check second and third row using the checkbox column. Normally, mygrid.getChangedRows() would now result in "1,2,3". But I'd like to have only the edited rows, an ouput of "1". Do you have any suggestions concerning this problem?
Answer posted by dhxSupport on Mar 24, 2009 09:39

It can be done only with code modification in file dhtmlxgrid.js:

this.getChangedRows=function(){

...

  for (var j = 0; j < cols; j++)
  if (row.childNodes[j].wasChanged){
  res[res.length]=row.idd;
  break;
  }
  })
  return res.join(this.delim);
 };

can be replaced this this:

  for (var j = 0; j < cols; j++)
  if ((row.childNodes[j].wasChanged)&&(this.getColType(j)!="ch")){
  res[res.length]=row.idd;
  break;
  }