Search code examples
jqgridcellparam

Change a Value of the columnModel JQgrid after draw


when i draw the grid i have some column like this..

name: 'codigo', index: 'codigo', width: 50, align: 'center', editable: true }

But after i want to do a query and then set the editable option, for example to false, is this possible?

Thanks.


Solution

  • You can get reference to internal colModel using getGridParam:

    var colModel = $("#grid").jqGrid("getGridParam", "colModel");
    

    Now you can enumerate elements in colModel array and find the element which has property name with the value "codigo". After that you can modify editable property of the element of colModel array. Look at getColumnIndexByName function from the answer for a code example.

    The most simple way to do what you want is the usage of setColProp method

    $("#grid").jqGrid("setColProp", "codigo", {editable: false});