You can hide/show any editable column inside of beforeShowForm
or afterShowForm
callback. It's important to understand that jqGrid fill the form with all editable columns. The form contains rows. Every row have id which build based on the name
of editable column. The row id have "tr_"
prefix which are appended to the column name (the value of name
property in colModel
). So if you need to hide the column having name: "Name"
then you can do
beforeShowForm: function ($form) { $form.find("#tr_Name").hide(); }
or just
beforeShowForm: function () { $("#tr_Name").hide(); }
(see the answer).
To get rowid which will be currently editing you can use
var rowid = $form.find("#id_g").val();
or
var rowid = $("#id_g").val();
(see the answer). The strange id value "id_g" is the id of hidden element which will be placed by jqGrid in every editing form. Alternatively you can use
var rowid = $(this).jqGrid("getGridParam", "selrow");
because the value from selrow
also contains the rowid of the current editing row.
To test content of another column before hiding/showing the row you can use getCell
. In case of datatype: "local"
(or in case of usage loadonce: true
) you can get object with full row data using getLocalRow
method.