获取 jqGrid 中的所有行 ID [英] Get all row IDs in jqGrid
问题描述
如何获取网格中每一行的 ID,甚至跨页面?
How can one get the ID's of every row in a grid, even across pages?
getDataIDs
和 getRowData
只给出当前页面的 ID.
getDataIDs
and getRowData
only gives the ID's of the current page.
谢谢!
推荐答案
只有当你有本地网格(datatype:'local'
或有loadonce:true
时才有可能>).在这种情况下,所有页面的所有包含数据的 id 都已经在本地.在这种情况下,您可以使用 _index
参数,该参数通常与另一个更知名的参数 data
一起使用.与
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');
您将获得 _index
参数.它是一个对象,具有网格的所有 id 作为属性.所以你可以用
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');
}
}
这篇关于获取 jqGrid 中的所有行 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!