I'm trying to implement inline inserting in a JQGrid. My approach thus far is:
- Use
addRowData
to put a blank row at the end with ID=-1 - Use
editGridRow
to edit that row - Detect on the server that this update is actually an insert because ID=-1, and return the new ID value
Suprisingly, this rube goldberg scheme works pretty well. To make it seamless, though, I'd like to silently update the ID of the row that was just added, so that the user can continue to edit the other columns. I'd rather not do a grid.trigger("reloadGrid")
, because I lose focus on that row.
I've tried
grid.setRowData(-1, { MyPrimaryKeyField: newID });
but that doesn't work (it still thinks the row's ID is -1). Is there an easy way to change the primary ID of a row without reloading the whole grid?