Get all row IDs in jqGrid

后端 未结 4 505
攒了一身酷
攒了一身酷 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:22

    In later versions of jqGrid they came out with a function that suits this situation better as it will consider any toolbar filtering that may be in place. See Oleg's example here. Thus, if you have a jqGrid (loadonce:true and/or datatype:local) the following will return all row ids (displayed in current page and beyond) which match the current filtering.

    var allIdsWithFiltering = grid.jqGrid('getGridParam', 'lastSelectedData');
    

    This returns a plain array, unlike the original answer, which returns an object with properties that must be enumerated.

提交回复
热议问题