jqGrid filterToolbar 在搜索时传递 _search:false

发布于 2024-12-05 17:19:18 字数 1479 浏览 0 评论 0原文

我已经使用 jqGrid 几个月了,我已经使用 filterToolbar 选项制作了一些数据网格:

$('#grid_id').jqGrid('filterToolbar');

它在过去工作得很好(将 POST 变量数组传递到 url 选项中定义的 php 页面) jqGrid定义,其中有一个变量“_search:true”)。我制作的最新网格,在我按 filterToolar 上的 Enter 键后,它只是重新加载网格...将“_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脚本)。

任何帮助将不胜感激。

谢谢。

I have been using jqGrid for a few months now, and I have made a handful of data grids with the filterToolbar option:

$('#grid_id').jqGrid('filterToolbar');

It has worked perfectly in the past (passing an array of POST variables to the php page defined in the url option in the jqGrid definition, of which there is one variable "_search:true"). The most recent grid I made, after I press enter on the filterToolar, it just reloads the grid... passing "_search:false" to the php script. Does anyone know why this would be happening. here is the script;

$('#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');

Like I said, it all works except when I try the toolbarFilter search, it just reloads the grid (passing "_search:false" to the php script).

Any help would be greatly appreciate.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魔法少女 2024-12-12 17:19:18

所以我通过一点尝试和错误找出了这个问题。 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
});

So I figured out the problem with a little trial and error. The filterToolbar was referencing the column names in the colModel, and not the index, which it should be referencing. So in the colModel option in the jqGrid definition I have to change the names to the real names in the database, and then add the other colName option to reset the column headings in the web page. See the following code:

$('#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
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文