Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 337
Donald Taylor Avatar asked Jun 20 '11 18:06

Donald Taylor


1 Answers

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');
    }
}
like image 134
Oleg Avatar answered Sep 29 '22 23:09

Oleg