How to get data for all rows in jqgrid with pagination
How to get data for all rows in jqgrid with pagination
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?
name = griddata[i].Name;
4 Answers
4
you can try using :
var allRowsInGrid = $('#list4').jqGrid('getGridParam','data');
worked for me also!
– Doctor Parameter
Nov 3 '16 at 19:24
This way is more "pretty":
var allRowsInGrid = $('#list4').getGridParam('data');
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);
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);
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
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.
– Michal Vašut
May 4 '15 at 16:28