Q:

jqGrid: How can I add columns to the edit modal that are read only?

I want to add a couple of columns to the edit dialog that are read-only in order to show users which row of data they are editing.  The selected row only gets highlighted very faintly so it's hard for users to tell which row of data they are editing.  Is there a way to add columns to the edit modal and make them read-only?
Here's what I've tried but none of them work.  Maybe there is some Javascript-ism that I don't have quite right, but I can't figure it out.
Has anyone been able to add columns to the edit modal that are read-only?
$("#prodTable").jqGrid('navGrid', '#pager', 
  { edit: true, add: false, del: false, search: false, refresh:true },
  { //  edit
    beforeInitData : function(formid) {
      console.log("beforeInitData formid: " + formid);
      //$("#" + "serialNumber").prop('readonly',true);
      //$("#prodTable_serialNumber").prop('readonly',true);
      //$("#prodTable_serialNumber").attr('readonly',true);
      //$("#jqgh_prodTable_serialNumber").attr('readonly',true);
      //$("#jqgh_prodTable_serialNumber").prop('readonly',true);
      $("#formid").prop('readonly',true);
    }
  }

A:

Form editing mode don't allows to insert non-editable fields in the editing dialog. It's one from the reason why usage of inline editing could provide more advantages. I like to use double-click to start inline editing. In the case the editable columns will be "converted" to controls like text <input>, dropdowns, checkboxes etc. If the user press Enter or "Save" button (depend on the form of inline editing which one use) the edited row will be saved.
If you still prefer usage of form editing then you can add required information about non-editable columns in at least two different ways. The first way would be adding properties
editable: true, editoptions: {disabled: "disabled"}

to non-editable columns. In the way the controls will be display, but disabled. To make look of the form better you can use additionally the approach which I described in the answer. You should just modify beforeShowForm callback from the answer to the following
beforeShowForm: function ($form) {
    $form.find(".FormElement[disabled]")
        .addClass("ui-state-disabled")
        .closest(".DataTD")
        .prev(".CaptionTD")
        .prop("disabled", true)
        .addClass("ui-state-disabled")
}

Another alternative to customize Add/Edit form: adding any required information manually. See the answer and this one for corresponding code examples and demos.

