I'm having issues with getting the correct row to select when using inline editing in jqGrid. No matter which row I click, the last row is selected, then with each additional click, the row above is selected. After all rows have been selected, then I can click and select any row. Here is my code:
I'm using jqGrid 4.4.4
//url for inline edit
editurl: "/Transactions/Modify",
//event for inline edit
onSelectRow: function (currentSelectedRow) {
if (currentSelectedRow) { // && currentSelectedRow != $.lastSelectedRow
//save changes in row
$('#grid').jqGrid('saveRow', $.lastSelectedRow, false);
$.lastSelectedRow = currentSelectedRow;
}
currentSelectedRow,
myEditParam = {
keys: true,
oneditfunc: function (id) { currentSelectedRow = id; },
afterrestorefunc: function (id) { currentSelectedRow = undefined; }
};
saveRowinstead ofeditRow. What behavior you try to implement? I recommend you to verify that you correctly fill rowids. The usage of$.lastSelectedRowlooks suspected too. Such code will not work in case of more as one grid on the page. jqGrid saves the ids of editing rows automatically insavedRowparameter which is array with rowids. Look at the code from the answer, wherebeforeSelectRowandonSelectRowcallbacks are used. It's the way, which I'd recommend you. It should work in jqGrid 4.4.4 too. - Oleg