0

In jqGrid for update/edit to work I have to make primary key columns editable.

But they should be editable only while adding a new record and not while updating an old record.

Is there a way to get around this issue? I guess this must be very common issue, but I did not find any solution to it.

Thanks in advance for helping me out.

YakovL
  • 7,557
  • 12
  • 62
  • 102
harish
  • 149
  • 1
  • 4
  • 14

2 Answers2

1

I hope that another my answer (having links to two another old answers) will solve your problem.

If you use server base datatype ('json' and 'xml') the server will generate ids always and you don't ever have to make id column editable.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • so thats kind of a workaround than an actual solution to the problem. its like having auto-generated ID column in db. But the requirement I have to apart from primary key column, i want to disable other columns also for editing based on business request. lets say persons address changes, but his birthdate wont. so once entered into the system i want to make sure that birthdate is disabled for editing. (just an example) – harish Mar 22 '11 at 05:32
  • 1
    @harish: If you use form editing you can hide the `id` and `birthdate` columns from in editing dialog inside of `beforeShowForm` (like [here](http://stackoverflow.com/questions/3405029/jqgrid-disable-form-fields-when-editing/3405961#3405961) will be disabled column `Name`). In the way you disable the columns be edited. In the `beforeShowForm` you can examine the current selected row and disable it based on more complex criteria of your "business request". If you use inline editing you can set `$("#list").jqGrid('getColProp','id').disable=false` before call of `editRow` and then change it back. – Oleg Mar 22 '11 at 07:25
0

If you are following the principle Inline editing you can indicate which columns you want to edit when entering on method onCellSelect or onSelectRow.

To do this you just need to change the property editable to the desired value:

$(this).getColProp('ColumnName').editable = false || true;
YakovL
  • 7,557
  • 12
  • 62
  • 102