简体   繁体   中英

How can I make a jqgrid with a subgrid load faster?

This is an example of the code I have. I left out the colNames and colModel because I know that's not the problem. I'm just wondering if there is any way to make a jqgrid that has a subgrid load faster. When this grid has > 100 records, it is fairly slow. If I remove the subgrid code and put gridview: true on the grid, it loads sooooooooooooooo much faster, but obviously, I can't have gridview: true and a subgrid. Any suggestions?

$(scheduleGridName).jqGrid({
    url: dataURL,
    datatype: "json",
    mtype: 'GET',
    colNames: [...],
    colModel: [...],
    height: "auto",
    width: '100%',
    rowNum: 2000,
    loadonce: true,
    jsonReader: {
        root: "SearchResults",
        records: "NumberOfResults",
        repeatitems: false
    },
    viewrecords: true,
    subGrid: true,
    subGridRowExpanded: getSubgrid
});

You have rowNum: 2000. So that is a lot of records plus a subGrid for each one. Try setting rowNum: 10. or a number that you find that loads fast enough. If that does not work then consider a different way to show the subgrid. You could create an "action" column that has a link to another grid to dig into the details.

This code example will add the html to the "Action" column.

gridComplete: function () {
    var ids = jQuery("#grid").jqGrid('getDataIDs');
    for (var i = 0; i < ids.length; i++) {
        var cl = ids[i];

        be = "<a href='../Company/EditUser?contactID=" + cl + "'>Edit</a></xsl:text>";
        jQuery("#grid").jqGrid('setRowData', ids[i], {
            Action: be
        });
    }
}
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM