Can I change the primary row identifier in JQGrid without reloading?

I am trying to inject inline insertion into JQGrid. So far my approach is:

  • Use addRowData to put an empty string at the end with ID = -1
  • Use editGridRow to edit this row.
  • Determine on the server that this update is actually an insertion since ID = -1 and returns a new ID value

Surprisingly, this rube goldberg circuit works very well. However, to make it seamless, I would like to quietly update the identifier of the row just added so that the user can continue to edit other columns. I would rather not do grid.trigger("reloadGrid") because I am losing focus on this row.

I tried

 grid.setRowData(-1, { MyPrimaryKeyField: newID }); 

but this does not work (he still considers the row id to be -1). Is there an easy way to change the primary row id without reloading the entire grid?

+7
jqgrid
source share
2 answers

In fact, you cannot change the primary identifier of the grid lines to "setRowData", but there is an easy way to do this:

 $("#-1").attr('id',newId); 

; -)

+7
source share

You can get around this by making an AJAX call to insert and return a new identifier. Once you have the identifier, call reloadGrid, and then select the row using the new returned identifier. You will also want to place a counter at the top while you are doing this so that the user knows that your page is busy. Not exactly what you ask for, but it should meet your needs.

+2
source share

All Articles