Hopefully this is a quick one!
I have an editable grid using 'clientSide' (local) data and I now wish to iterate all the rows in javascript and process/package the data myself before sending it to the server via a jQuery.ajax call.
The problem is that, unexpectedly (for me at least), using the following code only retrieves the rows for the currently visible grid page! How can I get ALL the rows in the grid (i.e. I have four pages of 10 records each and this code only returns the first 10 when I'm on page 1)? They must be present in the client somewhere because I can page around and edit the rows and the data is persisted without calling the server! :)
cacheCONF = [];
var rows= $('#myGrid').getRowData(); //<--Need to get ALL rows here!!!
var cacheRowID = 0;
for (var row in rows) {
if (rows[row].Action == 'Yes') {
cacheCONF.push({ RowID: rowID, System: rows[row].System, Action: rows[row].Action, Account: '-', Required: '-' });
rowID++;
}
}
Solution from Tony:
var mydata = $("#grid").jqGrid('getGridParam','data');
Had encountered a similar problem, below is what I ended up using
var data = $("#table-id").jqGrid('getGridParam', 'data');
for (var i = 0; i < data.length; i++) {
var f_name = data[i].FirstName;
var l_name = data[i].LastName;
// blah... blah..
}
Reference : http://www.trirand.com/blog/?page_id=393/help/jqgrid-getdata-only-returns-data-for-current-page/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With