Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid getData only returns data for current page

Tags:

jqgrid

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++;
        }
    }
like image 377
jqwha Avatar asked Jul 22 '10 08:07

jqwha


2 Answers

Solution from Tony:

var mydata = $("#grid").jqGrid('getGridParam','data');
like image 126
jqwha Avatar answered Dec 03 '22 00:12

jqwha


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/

like image 26
Yasser Shaikh Avatar answered Dec 03 '22 01:12

Yasser Shaikh