javascriptjqgridfree-jqgrid

How can you stop scrolling on JqGrid when editing in batch mode


The JqGrid example at http://www.guriddo.net/demo/guriddojs/edit_add_delete/inline_batch/index.html shows how to use 'batch editing'. However when the edit button is clicked, focus scrolls to the last rows initial edit column. How can that be made to focus on the first row instead? Also how can it be used with paging?


Solution

  • The first requirement can be accomplished if you loop in reverse order, since the ids are get from the first row to the last - i.e. the function startEdit can look like:

    function startEdit() {
        var grid = $("#jqGrid");
        var ids = grid.jqGrid('getDataIDs');
    
        for (var i = ids.length - 1; i >= 0; i--) {
            grid.jqGrid('editRow',ids[i]);
        }
    }
    

    As for the other requirements it depends what should be done when the new page is requested - to save existing edits or cancel them.

    For this purpose it is needed to use onPaging and maybe onSortCol (in case of sorting) events, but all depend on the specific requirements above