How to get data for all rows in jqgrid with pagination
Asked Answered
F

4

13

I want to access grid data as below

    var namePresent;
    var datafromgrid = $('#MyGrid').jqGrid('getRowData');
    for (var i = 0; i < rowCount; i++) {
         var name = datafromgrid[i].Name;
         var firstname = name.split(/ +/);
         if (firstname[0].toLowerCase() == Name.toLowerCase()) {
             namePresent = 1;
         }
    }

Now suppose when my grid is loaded with 5 records then this code throws error on line var name = griddata[i].Name; as from grid it is unable to read griddata[5]. Please tell me how to read whole grid data even if it is not visible on screen but is fetched successfully?

Forestall answered 31/10, 2013 at 9:58 Comment(0)
S
27

you can try using :

var allRowsInGrid = $('#list4').jqGrid('getGridParam','data');
Signe answered 7/11, 2013 at 5:49 Comment(1)
WOW!!! You are my HERO!!! Thank you very much!!! I have very customized grid where one cell can have multiple inputs and your code allows me to manipulate local data and then send them to server.Eringo
T
6

This way is more "pretty":

var allRowsInGrid = $('#list4').getGridParam('data');
Tejeda answered 11/9, 2015 at 18:50 Comment(0)
N
3

This is an alternative way to get the data of a particular row. You can loop over all rows to get everything:

var dataIDs = grid.getDataIDs(); 
for(i = 0; i < dataIDs.length; i++)
{
    var rowData = grid.jqGrid ('getRowData', dataIDs[i]);
    //rowData is object containing keys & values for row
    console.log(rowData);
}
Nuggar answered 26/8, 2018 at 1:40 Comment(0)
W
-3

After digging into the documentation, found this straight forward way.

var allRowsInGrid = $('#list4').getGridParam('data');

This returns you a JavaScript Array Object. To check the values in JS Object you can simply use following way.

var stringVersion = JSON.stringify(allRowsInGrid);

alert (stringVersion);
Waverly answered 13/2, 2017 at 13:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.