具有用户自定义高级搜索和 addJSONData 填充的 jqGrid [英] jqGrid with user-custom advanced search and addJSONData population

查看:13
本文介绍了具有用户自定义高级搜索和 addJSONData 填充的 jqGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直想创建自己的搜索对话框来创建与 jqGrid 文档中提到的方法不同的搜索条件.这有很多原因,包括但不限于对日期范围的良好支持、更人性化的搜索对话等.

我只是想知道是否有人尝试过创建此流程,以及在开始实施之前创建自己的复杂搜索作为一种变通方法的效果如何:

  1. 创建一个对话框,用户在其中插入搜索所需的信息(不同于 jqGrid 高级自定义搜索的当前信息)
  2. 发送到服务器并以 JSON 格式检索的请求,我可以使用 addJSONData 方法将其插入到网格中.
  3. jqGrid 将保留搜索值的分页,以便在 nextprevious 按钮后分页将正常工作(使用基于搜索条件获取的数据)被击中.

所以 问题 是:如果我更改 filters 使用 setGridParam 包含在搜索导航过程中使用的相同 data.当 onPaging 事件被触发并且使用简单的逻辑指示正在为搜索的数据进行分页时,可能会发生这种情况?

非常感谢.

解决方案

首先我可以提一下,我对自定义搜索对话框的实现有点悲观.原因是您将在实施中投入大量时间.我会建议您在 standard 搜索对话框中使用自定义控件.应用我建议的 .在这种情况下,您可以利用本地数据过滤(datatype: 'local' 或使用 loadonce: true).以 答案 中的演示为例.

如果你只想在服务器端实现数据过滤,你可以使用任何格式的附加属性(请不要使用同名filters).如果您想在页面上始终显示搜索过滤器(控件),我建议您使用具有 postData 属性的技术作为函数(请参阅 答案).

I have been fancying the idea of creating my own search dialog to create the search criteria that differs from the approach mentioned in the jqGrid documentation. This for many reasons, including but not limited to the good support of date ranges, more user-friendly search dialogue , etc.

I just would like to know if anyone has attempted the creation of this flow and how effective it is as a workaround to create your own complex search before diving into implementing it:

  1. create a dialog where user insert the information required for search (different than the current one for the advanced custom search of jqGrid)
  2. The request sent to the server and retrieved as JSON which I can insert in the grid using addJSONData method.
  3. jqGrid will preserve the paging for the searched values such that the paging will work correctly (with the fetched data based on the search criteria) once the next and previous buttons are hit.

So the question is: can I make the next and previous navigations work for me if I change the filters using setGridParam to include the same data used in the search for the process of navigation. This could happen when the onPaging event is triggered and with simple logic which dictates that the paging is happening for a searched data?

Thanks a lot.

解决方案

First of all I can mention, that I am a little pessimistic about implementation of custom searching dialog. The reason is that you will invest much time in the implementation. I would you better recommend to use custom controls inside of standard searching dialog. After applying the changes which I suggested it is now possible.

Look at the demo which allows you to create searching dialog like

In the way you can solve many problems which you described in your question.

If you do decide to create custom searching dialog you will have to do the following:

  • The new searching dialog should add information about the searching criteria in postData properties.
  • reload the grid using .trigger.("reloadGrid")

You don't need make separate Ajax request to the server. Reloading of the grid is what you need to do.

If you want to save the information about the filter in the postData.filters you have to hold the standard format. In the case you can have advantage of local data filtering (datatype: 'local' or the usage of loadonce: true). See the demo from the answer as an example.

If you want to implement filtering of data on the server side only you can use any format of additional properties (please don't use the same name filters). If you want to have searching filter (controls) always visible on the page I would recommend you to use the technique with postData properties as function (see the answer).

这篇关于具有用户自定义高级搜索和 addJSONData 填充的 jqGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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