jqGrid multiselect, checked-box persist when move to the next page

前端 未结 6 880
忘了有多久
忘了有多久 2021-02-06 03:56

If you see jqGrid demo :

http://www.trirand.com/blog/jqgrid/jqgrid.html

Section : Advanced --> Multiselect

You\'ll see that the checked checkbox is not p

6条回答
  •  灰色年华
    2021-02-06 04:56

    This is fairly simple to do using the gridComplete and onPaging events plus the jquery .data() method. This is much simpler than a lot of the stuff I've seen floating around the net, so I thought I'd share it. The selector for my grid is '#employeerolegrid'.

           gridComplete: function () {
    
                var currentPage = $(this).getGridParam('page').toString();
    
                //retrieve any previously stored rows for this page and re-select them
                var retrieveSelectedRows = $(this).data(currentPage);
                if (retrieveSelectedRows) {
                    $.each(retrieveSelectedRows, function (index, value) {
                        $('#employeerolegrid').setSelection(value, false);
                    });
                }
            },
            onPaging: function () {
                var saveSelectedRows = $(this).getGridParam('selarrrow');
                var page = $(this).getGridParam('page') - 1;
    
                //Store any selected rows
                $(this).data(page.toString(), saveSelectedRows);
            }
    

提交回复
热议问题