jqgrid load large data set without pagination

后端 未结 2 981
挽巷
挽巷 2020-11-30 14:05

I was wondering whether there is a better way to load large Json data set from the server.

I am using jqgrid as loadonce:true. i need to load around 1500 records at

相关标签:
2条回答
  • 2020-11-30 14:46

    On example of this demo you can see the time of loading 1500 rows for your grid in case of usage of gridview: true.

    The most performance problem of your example are inside of loadComplete function. If you do need to make some modifications on the grid you should use jQuery to manipulate the grid contain. The best performance you can archive if you use DOM elements of the grid directly like in the example

    loadComplete: function() {
        var i=0, indexes = this.p._index, localdata = this.p.data,
            rows=this.rows, rowsCount = rows.length, row, rowid, rowData, className;
    
        for(;i<rowsCount;i++) {
            row = rows[i];
            className = row.className;
            //if ($(row).hasClass('jqgrow')) { // test for standard row
            if (className.indexOf('jqgrow') !== -1) {
                rowid = row.id;
                rowData = localdata[indexes[rowid]];
                if (rowData.amount !== "200") {
                    // if (!$(row).hasClass('ui-state-disabled')) {
                    if (className.indexOf('ui-state-disabled') === -1) {
                        row.className = className + ' ui-state-disabled';
                    }
                    //$(row).addClass('ui-state-disabled');
                }
            }
        }
    }
    

    You can see the corresponding example live here.

    In the implementation of loadComplete function I use the fact, that jqGrid having loadonce:true parameter use internal parameters _index and data which can be used to access the contain of the grid. In the example I disabled the rows which not contain "200" in the amount column.

    UPDATED: The answer describes how to use rowattr callback to simplify the solution and to have the best performance (in case of gridview: true of cause).

    0 讨论(0)
  • 2020-11-30 14:55

    I would be tempted to look into the Autoloading on scroll feature of jqGrid. I would never load 1500 rows upfront. Any reason you cannot page?

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