且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jqGrid的过滤器工具栏和日期,并选择过滤器

更新时间:2023-10-26 12:27:10

我同意的官方文档只能用更多的参考,而不是引进为开发谁开始使用它,尤其不适合.NET开发人员。

I agree that the official documentation can be used only more as reference and not as the introduction for developer who start to use it, especially not for .NET developer.

要你的问题:

1),有落实的日期范围搜索没有简单的方法。人们可以做一些小把戏,比如招描述这里 filterToolbar beforeSearch 回调或 onSearch 回调的用法高级搜索允许pre-进程搜索过滤器将被应用之前,但都在一起是非常棘手的。在使用服务器端的情况下,排序可以实现直接在服务器端一样的。

1) There are no simple way to implement searching by range of dates. One could make some tricks like the trick described here. The usage of beforeSearch callback of filterToolbar or onSearch callback of advanced searching allows to "pre-process" searching filter before it will be applied, but all together is very tricky. In case of usage server side sorting you can implement the same on the server side directly.

2)要实现jqGrid的下拉菜单许多方面。主要的替代品 dataUrl searchoptions 。***的选择取决于您的具体要求。

2) There are many ways to implement drop downs in jqGrid. The main alternatives are the usage of value or dataUrl properties of searchoptions. The best choice depend on your exact requirements.

的使用是非常实用的,如果列有一些小的一套是动态比较静态的价值。例如,如果你使用格式复选框,在网格中显示布尔数据为复选框你想确保使用下拉菜单中的过滤器的列。在这种情况下设置如下图所示的使用

The usage of value is very practical if the column have some small set of values which are more static as dynamic. For example if you use formatter: "checkbox" in the grid to display boolean data as checkboxes you would like sure to use drop downs in the filter for the column. In the case the usage of settings like below

stype: "select", searchoptions: { sopt: ["eq", "ne"], value: ":All;true:Yes;false:No" }

将非常实用。顺便说一句,你可以在对象表单中使用

value: {"": "All", true:"Yes", false: "No"}

在其他情况下,如果你有小数量的值可以使用来实现搜索过滤器的下拉列表中。

In other cases if you have small number of values you can use value to implement dropdowns in the searching filter.

dataUrl 的用法,如果值的列表中,您从数据库中动态获取,应该使用。我可以解决你答案这也解释了相应的实施的主要思想。

The usage of dataUrl one should use if the list of the values you get dynamically from the database. I can address you to the answer which explains the main idea of the corresponding implementation.

答案显示简单的纯JavaScript code其中演示了如何一个CAN实现在客户端上选择和自动完成只要。在服务器端分页的情况下,和过滤应该选择另一种方式实现。 答案显示了一种如何在ASP.NET MVC解决方案中实现jQuery UI的自动完成。

The answer shows simple pure JavaScript code which demonstrate how one can implements selects and autocomplete on the client side only. In case of server side paging and filtering one should choose another implementation way. The answer shows how one can implement jQuery UI Autocomplete in ASP.NET MVC solution.

我觉得jQuery UI的自动完成功能可以很好的替代选择在某些情况下,特别是如果可能的选项的数目是非常大的。

I think that jQuery UI Autocomplete could be good alternative to select in some cases, especially if the number of possible options is very large.

更新时间::有许多方法可以使搜索不区分大小写。在使用的本地的搜索(使用数据类型等为JSON或 XML或 loadonce的使用:真正的)应该只使用 IGNORECASE:真正的$ C 。$ C>的jqGrid的选项在的服务器端的搜索,你应该在服务器端搜索不区分大小写的情况的我用个人刚刚的过滤中COLLATE 。例如,而不是结构,如

UPDATED: There are many ways to make searching case insensitive. In case of usage local searching (usage datatype other as "json" or xml" or usage of loadonce: true) one should just use ignoreCase: true option of jqGrid. In case of server side searching you should make searching insensitive on the server side. I use personally just COLLATE during filtering. For example instead of constructs like

WHERE Name LIKE ('%' + @s + '%')

我用

WHERE Name COLLATE SQL_Latin1_General_CP1_CI_AS LIKE ('%' + @s + '%')

有关code,你一发布更多的小备注:

One more small remarks about the code which you posted:


  • 使用的总是 GridView控件:真正的选项。请参见答案了解更多详情。

  • 始终指定寻呼机形式呼叫器:#jqgPagerFileInfoList,而不是形式寻呼机:$(#jqgPagerFileInfoList)

  • 不要使用类似不存在的选项刷新:真正的

  • 我建议你使用 AUTOEN code:真正的选项强制间preT从服务器作为文本返回,而不是HTML片段中的数据。如果没有选择,你可能有问题,显示具有textes < &放大器;

  • 我建议你检查 colModel 属性的默认值(见的文档)。你会看到,你可以从你的code删除对齐:'左' sorttype:文本搜索:真正的

  • 您应该使用允许 colModel 属性的山谷。例如宽度:'100%'是不正确的,将是PTED为默认值间$ P $ 宽度:150

  • 您使用 jsonmap 相同名称属性的值的所有值。所以,你可以删除该值。

  • 我建议你删除隐藏的列名称:ID&LT的使用的jqGrid ID 属性; TR> 从而重新网格present行。您可以使用 repeatitems:假 jsonReader 内部。您可以在 jsonReader 添加属性 ID:ID来指定的jqGrid应该使用 ID从的rowid行数据项的属性。

  • use always gridview: true option. See the answer for more details.
  • specify the pager always in the form pager: "#jqgPagerFileInfoList" instead of the form pager: $("#jqgPagerFileInfoList").
  • don't use non-existing options like refresh: true
  • I recommend you to use autoencode: true option to force interpret the data returned from the server as text and not as HTML fragments. Without the options you could have problems to display textes having <, & etc.
  • I recommend you examine default values of colModel properties (see the documentation). you will see that you can remove from your code align: 'left', sorttype: 'text', search: true etc.
  • You should use permitted vales for properties of colModel. For example width: '100%' is incorrect and will be interpreted as default value width: 150.
  • all values which you use for jsonmap are the same as the value of name property. So you can remove the values.
  • I recommend you remove hidden column name: 'Id'. jqGrid use id attribute of <tr> which represent rows of grid. You use repeatitems: false inside of jsonReader. You can add in jsonReader the property id: "Id" to specify that jqGrid should use "Id" property of items from the row data for rowids.