Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Luc on May 28, 2009 02:22
open dhtmlx forum
radiobutton or checkbox in my grid in mode Read Only

I wanted to know how can I do in order to have radiobutton or checkbow in my grid in mode "Read Only".
I don't want the customer could modify the value (true or false).
Thanks
Answer posted by dhxSupport on May 28, 2009 02:55
You can disable checkboxes/radiobuttons using setDisabled(true) method:
mygrid.cellById(rowId,cellIndex).setDisabled(true)
http://www.dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Excell_API_reference.html#grid_excellsapi
Answer posted by plamen on Jun 10, 2009 02:15

Hi,

I have similar question to the one posted here. I set my checkboxes to readonly by:

function disableCheckBoxes(grid) {
  var colNum = grid.getColumnsNum();
  for (var i = 0; i < colNum; i++) {
    if (grid.getColType(i) == 'ch') {
      disableCol(grid, i);
    }
  }
}

Later on, I update the values of particular cells by using an API call:

mygrid.cells(id, i).setValue(xxx);

The cells remain read-only (non-clickable), but they are no longer drawn as disabled! In fact, they look much better now! (see the attached snapshot, rows #3 and 5)

How to achieve this effect from the very beginning?

Regards,

Plamen

Attachments (1)
Answer posted by Alex (support) on Jun 10, 2009 09:56

Hello,

in this case instead of disabling checkboxes you can use onEditCell to block editing for "ch" column:

grid.attachEvent("onEditCell",function(stage,id,index){

  if(index == ch_index) return false
  return true

})

Here ch_index is index of ch column.