Issue while reloading jqgrid with scroll:true, initiates multiple ajax calls to load data
I have a jqgrid on my page which loads the first page of data while initializing. The scroll appears if there are more pages.
Problem is, if i scroll downs to see the second page and then trigger reloadGrid with updated url, it instantiates two ajax calls, with different page number (1 then 2).
In a result, grid is loaded with duplicate data returned against each call.
The above problem didn't appear if i didn't scroll down on first load.
jqGrid Creation Code:
$("#myGrid").jqGrid({
url: 'test.do',
datatype: 'json',
mtype: 'POST',
colNames: ['', 'Item No.', 'HS Code', 'Goods Description', 'Quantity', 'Value', ''],
colModel: [{name:'itemId', index:'itemId', hidden:true},
{name:'itemNo', index:'itemNo', width:100, align:'center', sortable:false},
{name:'hsCode', index:'hsCode', width:100, align:'center', sortable:false},
{name:'goodsDesc', index:'goodsDesc', width:350, align:'left', sortable:false},
{name:'itemQuantity', index:'itemQuantity', width:110, align:'right', sortable:false},
{name:'itemValue', index:'itemValue', width:110, align:'right', sortable:false},
{name:'action', index:'action', width:60, align:'center', sortable:false}],
width: 1000,
height: 230,
rowNum: 10,
shrinkToFit: false,
viewrecords: true,
emptyrecords: "No Record Found.",
multiselect: false,
scroll: true,
jsonReader: {repeatitems:false, id:"0"}
});
Code for reloading grid with new URL:
newURL = 'test.do?itemNo=3';
jQuery("#myGrid").jqGrid('set开发者_StackOverflow中文版GridParam',{url:newURL,datatype:'json'}).trigger("reloadGrid",[{page:1}]);
AJAX calls after reload:
http://abc.com/test.do?itemNo=3&page=1
http://abc.com/test.do?itemNo=3&page=2
Any body have any idea why it is happening??
I have tried the following parameters in jqgrid creation script and it resolved the above issue:
set parameter scroll:1
instead of scroll:true
then add new parameter prmNames:{npage:1}
Reference: jqGridWiki:options in section: prmNames, scroll
精彩评论