Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by John on Sep 12, 2008 07:47
open dhtmlx forum
The question about cell 's editability

As I know that mygrid.setColTypes can be used to set column's editability.

However, is it possible to control particular cells's editability ? is there any build-in API ?

Thanks a lot.
Answer posted by Support on Oct 22, 2008 01:56
You can disable any cell by 

grid.cells(id,ind).setDisabled(true); // make cell at specified position readonly

Answer posted by John on Oct 23, 2008 23:03


I used grid.cells(id,ind).setDisabled(true); to set cells in first row with 6 columns to become read only. However,the error message said "r1 is not defined"
How can I solve the problem? Is there any other method to set cells in  one row read only.Thank a lot.


for(var ind=0;ind<6 ;ind++){
 grid.cells(r1,ind).setDisabled(true);

}


 <?xml version="1.0" encoding="UTF-8" ?>
 <rows>
 <row id="r1">
  <cell>AC</cell>
  <cell>ACC</cell>
  <cell>0.00</cell>
  <cell>0.00</cell>
  <cell>0.00</cell>
  <cell>0.00</cell>
  </row>
    </rows>

 

http://dhtmlx.com/docs/products/kb/index.php?s=normal&q=5028&a=7416 

Answer posted by Support on Oct 24, 2008 01:25
Probably the correct approach is

    grid.cells("r1",ind).setDisabled(true);

as "r1" is not the variable.

Also this method should be called after xml loading:

grid.loadXML(url,doAfterLoading);

function doAfterLoading(){
    for(var ind=0;ind<6 ;ind++){
        grid.cells("r1",ind).setDisabled(true);
    }
}
Answer posted by Support on Oct 24, 2008 01:26
a) The xml loading is async, you need to call the js comman only after data loading ( onXLE event or second param of loadXML ) 
b) can be set directly from XML as

 <row id="r1">
  <cell type="ro">AC</cell> 
  <cell type="ro">ACC</cell> 
  <cell type="ro">0.00</cell> 
  <cell type="ro">0.00</cell> 
  <cell type="ro">0.00</cell> 
  <cell type="ro">0.00</cell> 
  </row>