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

前端 未结 2 905
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 10:02

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.

                 


        
相关标签:
2条回答
  • 2020-11-29 10:34

    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.

    0 讨论(0)
  • 2020-11-29 10:39

    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 :)

    0 讨论(0)
提交回复
热议问题