我已经使用jqGrid几个月了,我使用filterToolbar选项制作了一些数据网格:
$('#grid_id').jqGrid('filterToolbar');
它在过去完美运行(将一系列POST变量传递给jqGrid定义中url选项中定义的php页面,其中有一个变量“_search:true”)。在我按下filterToolar后输入的最新网格,它只是重新加载网格...将“_search:false”传递给php脚本。有谁知道为什么会发生这种情况。这是脚本;
$('#processed_list').jqGrid({
url:'/phpAJA?&sql=' + sql,
editurl: '/phpAJAX?sql=' + sql,
height: 225,
width: 600,
datatype: 'xml',
mtype: 'POST',
colModel:[
{name:"Invoice Num",index:"InvoiceNum",width:"8"},
{name:"Job Num", index:"JobNum",width:"8"},
{name:"Customer",index:"Customer",width:"16"},
{name:"Emailed To",index:"to_email",width:"16"},
{name:"Date Processed",index:"timestamp",width:"16"}
],
pager: '#pager',
rowNum:10,
rowList:[10,20,30],
sortname: 'invid',
sortorder: 'desc',
viewrecords: true,
gridview: true,
caption: 'Processed Invoices',
editable: false
});
$("#processed_list")
.jqGrid('navGrid', '#pager', {edit: false,add: false, del: false, search: false, refresh:true},{},{},{},{},{})
.jqGrid('navButtonAdd',"#pager",{
caption:"reprint invoice", buttonicon:"ui-icon-print", onClickButton:function(){ ...some function... }, position: "last", title:"", cursor: "pointer"
})
.jqGrid('filterToolbar');
就像我说的,这一切都有效,除非我尝试使用toolbarFilter搜索,它只是重新加载网格(将“_search:false”传递给php脚本)。
任何帮助都会非常感激。
感谢。
答案 0 :(得分:2)
所以我通过一些试验和错误找出了问题。 filterToolbar引用了colModel中的列名,而不是引用它应该引用的索引。因此,在jqGrid定义的colModel选项中,我必须将名称更改为数据库中的实名,然后添加其他colName选项以重置网页中的列标题。请参阅以下代码:
$('#processed_list').jqGrid({
url:'/phpAJAX?sql=' + sql,
editurl: '/phpAJAX?sql=' + sql,
height: 225,
width: 600,
datatype: 'xml',
mtype: 'POST',
colNames:["Invoice Num","Job Num","Customer","Emailed To","Time Sent"],
colModel:[
{name:"InvoiceNum",index:"InvoiceNum",width:"8"},
{name:"JobNum", index:"JobNum",width:"8"},
{name:"Customer",index:"Customer",width:"16"},
{name:"to_email",index:"to_email",width:"16"},
{name:"timestamp",index:"timestamp",width:"16"}
],
pager: '#pager',
rowNum:10,
rowList:[10,20,30],
sortname: 'invid',
sortorder: 'desc',
viewrecords: true,
gridview: true,
caption: 'Processed Invoices',
editable: false
});