Reputation: 3
I've implemented a JQGrid table with loadonce:true
like this :
jQuery("#list").jqGrid({
datatype: 'jsonstring',
datastr : maVarJSON,
colNames:['AA','BB', 'CC','DD','EE','FF'],
colModel :[
{name:'invid', index:'invid', align:'center'},
{name:'invdate', index:'invdate'},
{name:'amount', index:'amount', align:'right'},
{name:'tax', index:'tax', align:'right'},
{name:'total', index:'total', align:'right'},
{name:'note', index:'note'}
],
pager: jQuery('#pager'),
rowNum: 50,
rowList: [50, 100],
caption: '',
height: 470,
width: 1000,
loadonce: true
});
jQuery("#list").jqGrid('filterToolbar',{afterSearch: function(){
var rowsFiltered = jQuery("#list").getRowData();
}});
My problem is :
I have 500 rows in maVarJSON
. I see 50 rows and 10 pages.
I decide to filter my column AA. Only 100 rows accept this filter. So, I see 50 rows and 2 pages.
I would get the 100 rows data. (The method jQuery("#list").getRowData()
give me only the 50 first rows data.)
Thanks
Upvotes: 0
Views: 1023
Reputation: 11
You will push only the searched for rows across all pages to the obj.items object:
var obj = new Object();
var numpages = jQuery(id).getGridParam('lastpage');
obj.items = new Array();
var realname = id.split("_");
realname = "input_jqGridPager_" + realname[1];
var curpage = jQuery('#'+realname);
curpage = curpage.children('input');
curpage = curpage[0].value;
for (var i = 1; i <= numpages; i++)
{
jQuery(id).trigger("reloadGrid",[{page:i}]);
selRowIds = jQuery(id).jqGrid ('getRowData');
obj.count = selRowIds.length;
for(elem in selRowIds) {
obj.items.push(selRowIds[elem]);
}
}
jQuery(id).trigger("reloadGrid",[{page:curpage}]);
Upvotes: 1
Reputation: 222017
The method getRowData
get the data from the current page only. If you need get all the grid data you can use getGridParam
to get 'data'
parameters and get all grid data. I don't really understand what you want to do with the data inside of afterSearch
callback. The goal of filterToolbar
to display the data for the user and not to get you JavaScript interface to filter some JavaScript data.
By the way you can remove caption: ''
option which is default, remove loadonce: true
which will be ignored for local data inclusive datatype: 'jsonstring'
and replace pager: jQuery('#pager')
option to pager: '#pager'
. If you would use pager: jQuery('#pager')
jqGrid will have to convert it to pager: '#pager'
itself internally.
Upvotes: 0