Wednesday, 25 April 2012

jqGrid Ensure last edited cell is saved when save button clicked

I had a jqGRid that is shown in a jQuery dialog. The dialog has a save and cancel button. A problem occured where the last column in the grid was edited, but as the user did not press enter to commit the cell value, the last value entered in the grid was not saved when the 'Save' button was clicked. To get around this, I saved the current row and column indexes in the afterEditCell Method, then called my custom save cell method (saveCurrentCell) when the OK button is clicked on the jQuery dialog. This ensures that the last cell being edited is saved before the dialog is closed. Markup: Javascript: