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

前端 未结 6 875
忘了有多久
忘了有多久 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:43

    My solution: (define variable current_page and set in Event loadBeforeSend) because

    var page = $(this).getGridParam('page') - 1; not work.
    
    var current_page=0;
    

    ...

       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');
            //Store any selected rows
            $(this).data(current_page, saveSelectedRows);
        },
        loadBeforeSend:function(){
                        //set current page
            current_page = $(this).getGridParam('page').toString();
    }
    

    Function get multi select Values array

    function getSelectedValues(){
    
        var saveSelectedRows = $("#YourGrid").getGridParam('selarrrow');
    
        $("#YourGrid").data(current_page, saveSelectedRows);
    
        var retrieveSelectedRows = $("#YourGrid").data();       
    
        var arr_values = new Array();
    
        if (retrieveSelectedRows) {
            $.each(retrieveSelectedRows, function (index, value) {
                $.each(value, function (index, sub_value) {
                    if(typeof(sub_value)=='string')
                    arr_values.push(sub_value);
                });
            });
        }
    
        return arr_values;
    }
    

提交回复
热议问题