jqGrid cell in edit mode only for inline add

2.3k views Asked by At

How can I enable one column to be editable only if it's in a new row? This column must be read-only in existing rows when in edit mode.

The editable attribute works for new and existing rows.

1

There are 1 answers

4
Vinod Kumar On

What is the type of editing are you using? Form editing or inline editing?

If it is form editing you can use beforeShowForm event to hide the non-editable fields from the edit form.

beforeShowForm:function(formid)
{
 id="#tr_"+columnName(as given in column model);
 $(id, form).hide();
}

you need to make the hidden fields visible in add form again by using the same event

beforeShowForm:function(formid)
 {
  id="#tr_"+columnName(as given in column model);
  $(id, form).show();
 }

If it is inline editing before calling editRow, set editable flag to false

$('#gridId').jqGrid('setColProp',columnName,{editable: false}); 

and after editRow was over reset the editable flag to true to make editable for newly added rows

$('#gridId').jqGrid('setColProp',columnName,{editable: true}); 

Hope it helps....