0
votes

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; }
    };
1
You code use saveRow instead of editRow. What behavior you try to implement? I recommend you to verify that you correctly fill rowids. The usage of $.lastSelectedRow looks 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 in savedRow parameter which is array with rowids. Look at the code from the answer, where beforeSelectRow and onSelectRow callbacks are used. It's the way, which I'd recommend you. It should work in jqGrid 4.4.4 too. - Oleg
Thanks Oleg. I'm just trying to get the correct row to select when editing depending on where the user clicks. This should be built in functionality. I'm confused why it's not working. - vmil
I repeat that typical error could be wrong rowids. In other words the reason could be at the time of filling the grid and not on editing time. Examine the rowids on your grid. See the picture and the description for more understanding. - Oleg

1 Answers

0
votes

It's happens because the first column hasn't ID data. Reorder columns or make first hidden ID column.