jqGrid高级搜索对话框-具有下拉菜单的列 [英] jqGrid Advanced Search dialog - column which has dropdown selection

查看:112
本文介绍了jqGrid高级搜索对话框-具有下拉菜单的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有高级过滤器的jqGrid 4.3.1.一些是布尔类型的列(例如是/否"类型),当创建新的高级过滤器行时选择了列类型时,我会显示一个下拉列表. 例如.假设第2列是IsActive(布尔值)类型,选择此列后,我会显示一个下拉列表,而不是文本框. 覆盖jqGrid高级过滤器的代码如下:

I have a jqGrid 4.3.1 with Advanced filter. some of the columns which are boolean types like Yes/No types, I show a dropdown when the column type is selected when a new advanced filter row is created. E.g. Say column 2 is IsActive (Boolean) type and when this is selected I shown a drop down instead of the textbox. The code which overrides the jqGrid advanced filter is as follows:

var cols = grid.jqGrid("getGridParam", "colModel");
for (var i = 0; i < cols.length; i++) {
if (cols[i].stype && cols[i].stype == "select" && cols[i].searchoptions && cols[i].searchoptions.buildSelect && $.isFunction(cols[i].searchoptions.buildSelect)
&& !cols[i].searchoptions.dataUrl && !cols[i].searchoptions.value) {
cols[i].searchoptions.value = cols[i].searchoptions.buildSelect(null);
}

此代码曾经在4.3版本(4.3.1之前的一个版本)中可以正常工作 不知道是什么引起了问题,但是现在我的下拉列表显示为空白. 任何帮助表示赞赏!

This code used to work fine in 4.3 version (one version before 4.3.1) Don't know what is causing the problem but now my dropdowns appear blank. Any help appreciated!

推荐答案

您没有发布使用的buildSelect代码,因此很难说为什么代码失败.我最不了解的是为什么您根本拥有如此复杂的代码.如果您知道列IsActive具有布尔类型,并且想要在高级搜索"对话框中将其显示为具有是"和否"值的下拉列表,并将其显示在网格中并在编辑期间显示为复选框,则可以执行以下操作:

You don't posted the code of buildSelect which you use, so it's difficult to say why the code fail. What I don't understand mostly is why you has so complex code at all. If you know that the column IsActive has type Boolean and you want display it in the Advance Searching dialog as drop-down having "Yes" and "No" values and display it in grid and during editing as checkbox you can do the following:

{ name: "IsActive", template: myCheckboxTemplate }

您在mytemplateCheckbox中定义的位置类似

var myCheckboxTemplate = {
        formatter: "checkbox", align: "center", width: 20,
        edittype: "checkbox", editoptions: { value: "1:0" },
        stype: "select", searchoptions: { sopt: ["eq", "ne"], value: "1:Yes;0:No" }
    };

我永久使用的描述方法非常有效.与上面的代码的唯一区别是,我使用了格式化程序,而不是"checkbox".如果需要,可以从此处下载.

The described approach I use permanently and it works very well. The only difference from the code above is that I use "clickableCheckbox" formatter instead of "checkbox". If you want you can download it from here.

这篇关于jqGrid高级搜索对话框-具有下拉菜单的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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