通过jqGridImport恢复JQGrid时,搜索信息不正确 [英] When restoring JQGrid via jqGridImport search information is incorrect

查看:105
本文介绍了通过jqGridImport恢复JQGrid时,搜索信息不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jqGridExport导出数据后,我们使用jqGridImport导入.第一个问题是底部栏选项没有返回,因此我在之后添加了该代码.因此代码如下:

After having exported data using jqGridExport we import using jqGridImport. First problem was that the bottom bar options did not come back so I added that code after. So code looks like:

$("#list").jqGridImport({imptype: 'jsonstring', impstring: gridSettings})
.jqGrid('navGrid','#pager', { edit: false, add: false, del: false, search: true, refresh:true },
{},{},{},{closeOnEscape: true, multipleSearch: true, closeAfterSearch: true},{});

$("#list").jqGridImport({imptype: 'jsonstring', impstring: gridSettings})
.jqGrid('navGrid','#pager', { edit: false, add: false, del: false, search: true, refresh:true },
{},{},{},{closeOnEscape: true, multipleSearch: true, closeAfterSearch: true},{});

gridSettings字符串的关键部分是:
"postData":{"_search":true,
"nd":1301031279941,
"rows":20,
"page":1,
"sidx":"a.ID",
"sord":"asc",
"filters":{"groupOp":"AND","rules": [{"field":"fname","op":"bw","data":"T"}]}
}

The critical part of the gridSettings string is:
"postData":{"_search":true,
"nd":1301031279941,
"rows":20,
"page":1,
"sidx":"a.ID",
"sord":"asc",
"filters":{"groupOp":"AND","rules": [{"field":"fname","op":"bw","data":"T"}]}
}

除了搜索之外,其他所有内容都可以正常显示.上面的postData中的一行搜索是正确的,但是还有另一条搜索行,我只能将其描述为默认搜索行.如果我进入该行并从多个搜索框中删除该行,则一切都应该保持原样.

Everything comes up fine except for the search. The one line of search from postData above is correct but there is a second search line, which I can only describe as the default search line. If I go in and remove that line from the multiple search box everything is as it should be.

所以我的问题是首先,为什么当我使用jqGridImport进行还原时为什么多搜索不会恢复?
其次,有没有办法以编程方式删除第二条搜索行?

So my question is first, why does multipleSearch not come back up when I restore using jqGridImport?
Second is there a way to programmatically remove the second search line?

推荐答案

带有导航器的底部栏的行为是正确的,因为它不是作为网格的一部分实现的.因此,您确实必须另外设置它.您可以编写自己的设置导出和导入.

The behavior of the bottom bar with the navigator is correct because it is implemented not as the part of grid. So you really have to set it additionally. You can write you own export and import of the settings.

将在搜索对话框中添加最后一行的情况确实是一个小问题,可以使用以下代码解决:

The situation with the additional last line which will be added in the searching dialog is really a small problem which can be fixed with the following code:

var grid = $("#list");
...

grid.searchGrid(prmSearch);
if (typeof(grid[0].p.postData.filters) === "string" &&
    grid[0].p.postData.filters.length>0) {

    $("#fbox_"+grid[0].id).searchFilter().del();
}
$("#fbox_"+grid[0].id).searchFilter().close();

您可以在此处看到相应的演示.这是我的另一个演示的小修改. ="https://stackoverflow.com/questions/5283070/in-jqgrid-why-dont-toolbarfilter-and-multiple-search-filter-get-along-when-usin/5284375#5284375">旧答案.

You can see the corresponding demo here. It is a small modification of the demo from my another old answer.

顺便说一下,将在下一版jqGrid中使用的新过滤器不会出现问题(请参见演示

By the way the new filter which will be used in the next version of jqGrid will not have the problem (see the demo here).

这篇关于通过jqGridImport恢复JQGrid时,搜索信息不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆