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

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

问题描述

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

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. 创建一个对话框,用户可以在其中插入搜索所需的信息(与jqGrid的高级自定义搜索的当前信息不同)
  2. 发送到服务器并作为JSON检索的请求,我可以使用addJSONData方法将其插入网格中.
  3. jqGrid将保留用于搜索值的分页,以便一旦按下nextprevious按钮,该分页将正确运行(使用基于搜索条件的提取数据).
  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.

因此,问题是:如果我使用setGridParam更改filters以包含与data搜索导航过程.当触发onPaging事件并使用简单的逻辑来指示正在对搜索到的数据进行分页时,会发生这种情况吗?

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?

非常感谢.

推荐答案

首先,我对自定义搜索对话框的实现有些悲观.原因是您将在实施上投入大量时间.我最好建议在 standard 搜索对话框中使用自定义控件.应用更改后,我建议现在可以这样做.

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:

  • 新的搜索对话框应在postData属性中添加有关搜索条件的信息.
  • 使用.trigger.("reloadGrid")
  • 重新加载网格
  • The new searching dialog should add information about the searching criteria in postData properties.
  • reload the grid using .trigger.("reloadGrid")

您不需要向服务器发出单独的Ajax请求.您需要做的就是重新加载网格.

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

如果要在postData.filters中保存有关过滤器的信息,则必须按住答案中的示例作为示例.

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.

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

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天全站免登陆