Search code examples
jqueryjquery-pluginsjqgrid

Get all row IDs in jqGrid


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.

Thanks!


Solution

  • 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');
        }
    }