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

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

问题描述

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

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. 选择该运算符后,即可进行交易,而无需等待用户键入任何内容,或单击Enter(类似于onSelect).
  2. (可选)在选择了特定运算符后,禁用在该特定过滤器中键入任何内容的功能.

谢谢

塔尔.

推荐答案

感谢您指出定义自定义一元操作的问题.我提交了

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"(为空")和"nn"(非空")操作. 金额"列使用

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"]}

注释"列使用

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;
            }
        }
    }
}

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

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