出现原因###
//第一次查询时参数
var param = {userNo:111,userName:222,depId:1};
//第二次查询是参数
var param = {userNo:111,userName:222};
//执行方式,通过setGridParam
if(curPage.JqGridtable != undefined){
curPage.JqGridtable.jqGrid("setGridParam",{url:url,postData:param}).trigger("reloadGrid");
}else{
......
}
//最后第二次执行条件仍然为
var param = {userNo:111,userName:222,depId:1};
源码分析###
//源码中setGridParam方法有参数overwrite,当overwrite为true时,参数才会覆盖之前的;否则不覆盖
setGridParam : function (newParams, overwrite){
return this.each(function(){
if(overwrite == null) {
overwrite = false;
}
if (this.grid && typeof newParams === 'object') {
if(overwrite === true) {
var params = $.extend({}, this.p, newParams);
this.p = params;
} else {
$.extend(true,this.p,newParams);
}
}
});
},
解决办法###
//执行方式,增加参数overwrite为true
if(curPage.JqGridtable != undefined){
curPage.JqGridtable.jqGrid("setGridParam",{url:url,postData:param},true).trigger("reloadGrid");
}else{
......
}