Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Poncho on Oct 12, 2009 08:13
open dhtmlx forum
Single selection of a checkbox

Hi there, I'm working with dhtmlxGrid, I've got a column with checkboxes, but I need that only one of them is checked at time. How can I achieve this?

Thanks in advance...
Answer posted by Stanislav (support) on Oct 14, 2009 04:14
Why do not use radio-button instead?

If you really need to have checkboxes, you can use

grid.attachEvent("onCheck",function(id){
      if (this._busy_flag) return;
      this._busy_flag  = true;

      var ids = grid.getCheckedRows(ind);
      for (var i=0; i<ids; i++) 
           if (ids[i]!=id) grid.cells(id,ind).setValue(0);

      this._busy_flag  = false;
})


Where ind - index of the column with checkboxes