免费 jqGrid - “空"的自定义过滤规则和“非空" [英] Free jqGrid - A custom filter rule for "empty" and "not empty"

查看:24
本文介绍了免费 jqGrid - “空"的自定义过滤规则和“非空"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉可以添加到每个列过滤器旁边左侧下拉选择中的自定义操作.

I'm familiar with the custom operations that can bd added to the dropdown selection on the left next to each column filter.

我想要的是添加两种新类型的自定义运算符以进行过滤:1. 空的2. 不为空

What i'm after, is to add two new types of custom operators for filtering: 1. Empty 2. Not empty

虽然我本身知道如何实现这一点,但我对 Free JqGrid 中此类流程的 UX 存在问题.这是因为这两个自定义操作符一旦被选中就不需要用户的任何输入,所以用户在选择这个带有空值的操作符后必须点击输入"——非常混乱.

While I know how to achieve that per se, I have a problem with the UX of such flow within Free JqGrid. This is because these two custom operators don't need any input from the user once they were chosen, so the user will have to click 'enter' after choosing this operator with an empty value - very confusing.

我想知道的是如何实现以下考虑我已经定义了一个新的自定义运算符:

What I want to know is how to achive the following consider I already defined a new custom operator:

  1. 一旦我选择了这个操作符,就开始交易,无需等待用户输入任何内容,或点击回车(类似于 onSelect).
  2. 或者,在选择特定运算符后,禁用在该特定过滤器中键入任何内容的功能.

谢谢,

塔尔

推荐答案

感谢您指出定义自定义一元操作的问题.我提交了更改free jqGrid 允许在新选项 customUnaryOperations 中指定自定义一元运算.

Thanks for pointing of the problem of definition custom unary operations. I committed the changes of the code of free jqGrid to allow to specify the custom unary operations inside of new option customUnaryOperations.

演示 定义了两个自定义过滤操作:em"(为空")和nm"(非空")并使用金额"和注释"列中的操作.注释"列另外使用标准(预定义)nu"(is null")和nn"(is not null")操作.金额"列使用

The demo defines two custom filtering operations: "em" ("is empty") and "nm" ("isn't empty") and use the operations in "Amount" and "Notes" columns. The column "Notes" uses additionally the standard (predefined) "nu" ("is null") and "nn" ("is not null") operations. The column "amount" uses

searchoptions: {sopt: ["eq", "ne", "em", "nm"]}

和note"列使用

searchoptions: {sopt: ["cn", "bw", "ew", "eq", "bn", "nc", "en", "nu", "nn", "em", "nm"]}

此外,演示还使用了 customSortOperations 和新的 customUnaryOperations:

additionally the demo uses customSortOperations and new customUnaryOperations:

customUnaryOperations: ["em", "nm"],
customSortOperations: {
    em: {
        operand: "=''",
        text: "is empty",
        filter: function (options) {
            var v = options.item[options.cmName];
            if (v === undefined || v === "") {
                return true;
            }
        }
    },
    nm: {
        operand: "!=''",
        text: "isn't empty",
        filter: function (options) {
            var v = options.item[options.cmName];
            if (v !== undefined && v !== "") {
                return true;
            }
        }
    }
}

这篇关于免费 jqGrid - “空"的自定义过滤规则和“非空"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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