There is no direct way to get the necessary information. Inside jqGrid uses $. Jgrid.from to filter local data. The main code that uses $.jgrid.from inside addLocalData . To get the results that you need without studying all the code, I suggest using the fact that all the filtered data will be returned by the select $.jgrid.from (see the line of code). My suggestion is to catch the data before the data is cut to page size.
For this, I suggest using a subclass: rewriting the select method of the $.jgrid.from method. I will demonstrate the technique in the examples created to answer this as well .
In your case, the code will be
var oldFrom = $.jgrid.from, lastSelected; $.jgrid.from = function (source, initalQuery) { var result = oldFrom.call(this, source, initalQuery), old_select = result.select; result.select = function (f) { lastSelected = old_select.call(this, f); return lastSelected; }; return result; };
The lastSelected variable lastSelected saves an array of elements that are the results of the last sort or filter operation. Since $.jgrid.from is global, the data is not grid related. If you have more than one grid per page, this will be inconvenient. You can fix a minor flaw with the following line in the loadComplate code of each grid:
loadComplete: function () { this.p.lastSelected = lastSelected;
We introduce the new parameter jqGrid lastSelected , which will have a tight structure as data , but will contain only the last filtered data.
The following code will display the identifiers of the filtered data in an alert message
$("#getIds").click(function () { var filteredData = $grid.jqGrid('getGridParam', 'lastSelected'), i, n, ids = [], idName = $grid.jqGrid('getGridParam', 'localReader').id; if (filteredData) { for (i = 0, n = filteredData.length; i < n; i++) { ids.push(filteredData[i][idName]); } alert("tolal number of filtered data: " + n + "\n" + "ids of filtered data:\n" + ids.join(', ')); } });
I used the localReader.id parameter because the property name used for local data is usually id or _id_ . _id_ will be used when loading data from the server if the loadonce: true option is used.
Demo demonstrates the approach. If for one filter, for example, only data from FedEx, and then click the "Show Identifiers" button, you will see information about all filters, and not just about the data displayed on the current page:


UPDATED : the free jqGrid provides a new lastSelectedData option. See the demo for a list of demos .