jqGrid get all ids
Asked Answered
P

3

7

I've noticed a small bug with jqgrid that if you have virtual scrolling set to 1 and try and try to select all rows it doesn't actually select them all meaning when you call

$("#file-grid").jqGrid('getGridParam','selarrrow'); 

to get all selected row data it doesn't actually get all the data. I was wondering if there was a method to get all row ids, selected or not using jqgrid.

Petrous answered 18/7, 2010 at 20:51 Comment(2)
I take it that getDataIDs would exhibit the same problem, of only returning some if the ID's?Etter
Yup it only works for visible rows, not all of themPetrous
L
11

Use the following if you're not using pagination:

var allRowsOnCurrentPage = $('#file-grid').jqGrid('getDataIDs');
Lateritious answered 20/6, 2011 at 17:33 Comment(1)
-1 The question specifically asked how to get all rows; not just the ones that are visible. This only retrieves visible rows.Republican
T
4

could you try getRowData() with no parameters - it should return all of the rows in the grid:

var allRowsInGrid = $('#file-grid').jqGrid('getRowData');

I got this from the jqGrid wiki:

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods

Tartar answered 28/8, 2010 at 21:12 Comment(2)
This returns not only IDs, but all columns of each row.Lateritious
Also, this only returns data from the current page.Lateritious
N
0

You can use this code:

 var grid = jQuery("#mylist");
 var ids = grid.jqGrid('getDataIDs');

 for (var i = 0; i < ids.length; i++) {
    var rowId = ids[i];
 }
Narceine answered 12/6, 2018 at 7:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.