JQGrid how to make a column editable in the add dialog, but not during (built-in) changes

I have jQGrid with a column that I want to change only when adding a new row.

I have seen examples of how to do this when changes and additions occur in a dialog box, but is there a way to do this using inline editing?

I tried using grid.setColProp () in beforeShowForm: but this does not work (the column remains read-only and is missing from the add dialog).

Example of enabling / disabling a column based on a dialog:
http://www.ok-soft-gmbh.com/jqGrid/CustomFormEdit.htm

+8
javascript jquery editing jqgrid
Nov 29 2018-10-2919:
source share
1 answer

Since you are using an example from my old answers ( this and this ), I feel that I should answer your question as well.

In the old example, all fields that can be changed while adding or editing dialogs have the editable:true property. Fields that should only be displayed in the Add dialog box will be hidden inside the beforeShowForm event descriptor . Similarly, we can temporarily switch some fields to editable:false before calling the editRow method and reset back to editable:true immediately after the call:

 onSelectRow: function(id) { if (id && id !== lastSel) { grid.jqGrid('restoreRow',lastSel); var cm = grid.jqGrid('getColProp','Name'); cm.editable = false; grid.jqGrid('editRow', id, true, null, null, 'clientArray'); cm.editable = true; lastSel = id; } } 

You can see this live here .

UPDATE: Free jqGrid allows you to define editable as a callback function. See the wiki article . It allows you to make a column editable in some rows and keep it uneditable for other rows.

+18
Nov 29 '10 at 21:15
source share



All Articles