获取jqGrid中的所有行ID [英] Get all row IDs in jqGrid
问题描述
如何获取网格中每一行的ID,即使是跨页面的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
参数.它是一个具有grid的所有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屋!