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

查看:18
本文介绍了通过 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},{});

gridSettings 字符串的关键部分是:
<代码>"postData":{"_search":true,
"nd":1301031279941,
行":20,
页面":1,
"sidx":"a.ID",
"sord":"asc",
"过滤器":{"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 恢复时,multipleSearch 没有恢复?
其次,有没有办法以编程方式删除第二个搜索行?

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();

您可以在这里查看相应的演示.这是我的另一个 demo 的一个小修改="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天全站免登陆