Reputation: 61
i want to make a row in dhtmlx are read only but i want make the other row are editable with some condition like
id%2=0 are editable.
function doInitGrid(){
mygrid = new dhtmlXGridObject('mygrid_container');
mygrid.selMultiRows = true;
mygrid.setImagePath("codebase/imgs/");
mygrid.setHeader("No, Id, Kd Dep, Kd Prog");
mygrid.setInitWidths("30,50,60,60");
mygrid.setColAlign("left,left,left,left");
mygrid.setColTypes("ro,ro,ro,ro");
mygrid.init();
mygrid.load('test.xml');
}
Upvotes: 2
Views: 4750
Reputation: 11
You can write ed as setcolTypes
to make the column editable.
mygrid.setColTypes("ro,ed,ro,ed");
Upvotes: 0
Reputation: 4067
You can also control what is editable on the backend (the process that generates your test.xml data).
I have a fairly elaborate grid where I have the same need. I accomplished this by first setting up my column types using the setColTypes function. Majority rules, meaning if most of the rows for a column are edtxt, then I set it to edtxt here...
myGrid.setColTypes("link,edtxt,ron,ron,edn,edn,ron[=(c4*c15)+c5],edn,edn,ron[=(c7*c15)+c8],edn,edn,ron[=(c10*c15)+c11],ro,ro,ro");
Then for the columns I want to be of a different type I just assign the type while the xml is being build on the back end. I've removed the server-side code (in this case it was pl/sql that generated this xml)...
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row id="100">
<cell colspan="2" style="font-weight:bold;" type="ro">Inspections</cell>
<cell type="ro"/>
<cell type="ro"/>
<cell type="ro"/>
<cell type="ro"/>
<cell type="ro"/>
<cell type="ro"/>
<cell type="ro"/>
<cell type="ro"/>
<cell type="ro"/>
<cell type="ro"/>
<cell type="ro"/>
<cell type="ro"/>
<cell type="ro"/>
</row>
<row id="1">
<cell>BLAHBLAH^javascript:gotoRec(1745563)^_self</cell>
<cell id="jon"/>
<cell>0</cell>
<cell>0</cell>
<cell id="cticol1">100</cell>
<cell id="cticol2">200</cell>
<cell/>
<cell id="cticol3">0</cell>
<cell id="cticol4">0</cell>
<cell/>
<cell id="cticol5">1.11</cell>
<cell id="cticol6">2.22</cell>
<cell/>
<cell/>
<cell>10000277932021</cell>
<cell>444.4</cell>
</row>
</rows>
So even though some columns are editable, some are a link, etc..., the entire first row will be readonly because I overrode those colTypes in the xml which takes precedence.
Hope this helps.
Upvotes: 0
Reputation: 5144
You can use events to customize the grid's behavior. Something like next
mygrid.attachEvent("onEditCell", function(stage, id, index){
if (id%2) return false; //block edit operations
return true;
});
Upvotes: 3