jqgrid后台传参数
JScript code // 获得当前postData选项的值
var postData = $("#proList").jqGrid("getGridParam", "postData"); // 将查询参数融入postData选项对象
$.extend(postData, [color=#FF0000]$("#searchVoForm").serializeArray()[/color]);
$("#proList").jqGrid('setGridParam',{search: true}).trigger("reloadGrid", [{page:1}]);
HTML code
<s:form id="searchVoForm">
<table id="searchVoInfo" class="form_table" width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td class="td_title_right" width="10%"><s:label value="项目名称 "/></td>
<td width="40%" align="left"><s:textfield id="proName" name="searchVo.proName" size="30" maxlength="50" cssStyle="width:155px"/></td>
<td class="td_title_right" width="10%"><s:label value="建设地区"/></td>
<td width="40%" align="left"><s:textfield id="buildArea" name="searchVo.buildArea" size="30" maxlength="50" cssStyle="width:155px"/></td>
</tr>
</table>
</s:form>
<div style="padding: 4px 0px 4px 0px; text-align: center;">
<div id="searchId" onclick="searchProList();">查询</div>
<div id="clearId" onclick="clearParam();">清空</div></div>
<div id="proGrid" class="ui-layout-west ui-widget ui-widget-content"><table id="proList" width="100%"></table><div id="pager" style="width: 100%;"></div></div>
$("#list").setGridParam({postData:{"param1": "value1","param2": param2}}).trigger("reloadGrid");
假设jqgrid的id是list主要是改变postData的数据就行 更简单的是对象化form中所以要提交的控件
$.fn.serializeObject = function(){
var o = {}; var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined)
{
if (!o[this.name].push)
{
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;};
然后var serialformdate = $("form").serializeObject()$("#list").setGridParam({page:1, postData:serialformdate}).trigger("reloadGrid");
假设jqgrid的id是list主要是改变postData的数据就行 更简单的是对象化form中所以要提交的控件
$.fn.serializeObject = function(){
var o = {}; var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined)
{
if (!o[this.name].push)
{
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;};
然后var serialformdate = $("form").serializeObject()$("#list").setGridParam({page:1, postData:serialformdate}).trigger("reloadGrid");
提交所以form的数据导control了
每一天都要行动,在前进中寻求卓越。