Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Vaibhav Billore on Jan 21, 2009 21:37
open dhtmlx forum
Read-only checkbox

Dear Sir,
I wish have a read-only checkbox.
In xml, if I set:
type='ro'
then it shows 0 or 1 on UI i.e. the index and it is not showing the checkbox.
Please tell me the correct way to send the status of checkbox in xml and keep it read-only.

Thanks in advance.
Answer posted by dhxSupport on Jan 22, 2009 02:01
You cans use setDisabled(true) method for the  "co" column.

mygrid.loadXML("grid.xml", function(){
   for (var i=0; i<mygrid.getRowsNum(); i++){
      mygrid.cellByIndex(i,columnIndex).setDisabled(true);
   }
});
Answer posted by Vaibhav Billore on Jan 22, 2009 02:17
Dear Sir,
By this way, we will disable all the check boxes in that column. But, I want only selected rows to have disabled/read-only check boxes.

While generating the xml, I have the information regarding which all rows will be having a read-only check-box. But, I dont have this info. on the UI.

So, I there any way to set some flag or something in the xml itself?
Answer posted by Support on Jan 22, 2009 05:10
Starting from dhtmlxgrid 1.6 you can use any custom attributes in XML, so when generating XML you can have 

<row id="some" disable_checkbox="true"> ...

and later in js code

mygrid.loadXML("grid.xml", function(){
     mygrid.forEachRow(function(id){
             if (mygrid.getRowAttribute(id,"disabled_checkbox")
                    mygrid.cellById(id,columnIndex).setDisabled(true);
     });
});