Get all row IDs in jqGrid

后端 未结 4 514
攒了一身酷
攒了一身酷 2021-01-05 05:47

How can one get the ID\'s of every row in a grid, even across pages?

getDataIDs and getRowData only gives the ID\'s of the current page.

4条回答
  •  孤独总比滥情好
    2021-01-05 06:40

    It is possible only if you have local grid (datatype:'local' or having loadonce:true). In the case all data inclusive ids for all pages are already locally. In the case you can use _index parameter, which will be used typically together with another more known parameter data. With

    var idToDataIndex = $("#list").jqGrid('getGridParam','_index');
    

    you will get the _index parameter. It is an object which has as the properties all ids of grid. So you can enumerate the ids with

    var id;
    for (id in idToDataIndex) {
        if (idToDataIndex.hasOwnProperty(id)) {
            // id is the rowid.
            // to get the data you can use
            // mydata[idToDataIndex[id]] where
            // var mydata = $("#list").jqGrid('getGridParam','data');
        }
    }
    

提交回复
热议问题