简体   繁体   中英

How to disable editing for some cells in row editing of JQGrid?

When I click on any row of my Grid, All editable columns become editable.

I want some of the columns to be editable on each row separately.

                 Column 1,   Column 2,     Column 3             
ROW Number 1 - editable,     non-editable, non-editable  
ROW Number 2 - non-editable, editable,     non-editable    
ROW Number 3 - editable,     non-editable, non-editable  

Thanks in Advance

If you use inline editing mode and want to decide dynamically which cells of the row will be editable for example based on the contain of the cells you can do this in the way which I described here . You can do this with another method also:

$(this).jqGrid('setColProp', 'YouColumnName', {editable:false});

So you should just set editable to false or true before calling of editRow method. In the way you can implement any logic which you want.

UPDATE: Free jqGrid allows to define editable as callback function. See the wiki article . It allows to make the column editable in some rows and holding non-editable for other rows.

I had a similar requirement, just expanding on what Oleg already mentioned in his answer:

//get colModel properties
var cm = jQuery("#grid").jqGrid('getColProp','myColumn');

//some condition to enable or disable editing
cm.editable = false;

//always call editRow after changing editable property
jQuery('#grid').jqGrid('editRow', rowId, {});

//set default editable option
cm.editable = true;

Cheers :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM