How to show all rows in the jqGrid?

后端 未结 14 1559
心在旅途
心在旅途 2020-12-02 22:26

jqGrid exposes a property rowNum where you can set the number of rows to display for each page. How do you set the grid to just display ALL rows?

Right

相关标签:
14条回答
  • 2020-12-02 22:48

    resolved it with simple change: rowNum: inputDataArray.length

    where inputDataArray is the array that I am providing to the Grid.

    0 讨论(0)
  • 2020-12-02 22:48
    loadComplete: function (data) {
                    //set our "ALL" select option to the actual number of found records
                    $(".ui-pg-selbox option[value='ALL']").val(data.records);
    }
    

    This changes the "ALL" option to the actual number of records in the dataset.

    0 讨论(0)
  • 2020-12-02 22:49

    Even if it still appears in the doc that you cannot set rowNum to -1 as of jqGrid 4.5.4 it works again (maybe in earlier version too).

    0 讨论(0)
  • 2020-12-02 22:51

    jqgrid (3.5 anyway) doesn't seem to have an elegant built in way to do this. The best I have found so far is to add something like the following to your grid options:

    rowList:[10,20,30,100000000],
    loadComplete: function() {
        $("option[value=100000000]").text('All');
    },
    

    Where the 100000000 is some arbitrarily higher number than the maximum # of rows you will ever return, and the option[value=] line is so your user interface looks a little nicer. Jenky, but works for me.

    0 讨论(0)
  • 2020-12-02 22:51

    You can also go into jquery.jqGrid.js and change "rowNum:20" to "rowNum:Some-Really-Large-Number". When you define your jqGrid, don't specify rowNum. Then return your entire dataset back to jqGrid.

    0 讨论(0)
  • 2020-12-02 22:56

    I've got this working:

    $('#bla').jqGrid({
            ...
            'rowNum'      : 0,
            'loadOnce'    : true,
            'loadComplete': function(data) {
                $(this).jqGrid('setGridParam', 'rowNum', data.total);
            },
            ...
    });
    

    This works with and without the loadOnce option set to true. Note that you have to set the rowNum option to 0 first, if you leave out this option it'll still default to the 20 records to show. Also, I'm assuming you're returning the total rows from the server in the documented JSON reader format.

    0 讨论(0)
提交回复
热议问题