Free-jqgrid 4.15.4中的自定义过滤器记录 [英] Custom Filter records in Free-jqgrid 4.15.4

查看:63
本文介绍了Free-jqgrid 4.15.4中的自定义过滤器记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于免费jqGrid 4.15.4中的自定义过滤器,我有一个问题.我想实现一种搜索功能,如果我选择小于但不为null或为空"过滤器,则它应仅显示记录行,而该列不为null或为空.我能够从

I have one question regarding custom filters in free jqGrid 4.15.4. I want to implement a search functionality where if I select 'less than but not null or empty' filter then it should show only rows of records which column isn't null or empty. I am able to create custom filter which gives 'is null' or 'isn't null' from this thread. But when I tried to create for mine requirement, I wasn't able to figure out what operator I have to use for 'less than but not null or empty'.

例如,我已使用以下代码示例创建自定义过滤器:

for example, I have used this code sample to create custom filter:

 customUnaryOperations: ["lne"],
 customSortOperations: {
           lne: {
                operand: "<!=''",
                text: "less but not empty",
                filter: function (options) {
                    var v = options.item[options.cmName];
                    if (v !== undefined && v !== "") {
                        return true;
                    }
                }
            }

我在搜索选项工具栏中使用的上述运算符.

The above operator I've used in search option toolbar.

searchoptions: {
                     searchOperators: true,
                     sopt: ['eq', 'lt', 'gt','lne'],
                 }, search: true, 

同时,我不想使用 formatter:整数" (建议过滤器.

Meanwhile, I don't want to use formatter: "integer" (suggested here) as this only assigns 0 to all null record column cells, and still visible in records whenever one selects 'less than' filter .

作为参考,我创建了一个小提琴,其中包括要求和两个图像更清晰.那么,有人可以帮我这个忙吗?我希望我再次提出这个要求.

For reference, I've created one fiddle which consists of the requirement and two images for more clarity. So, Can anyone help me out on this? I hope I'vent re-asked this again.

谢谢.

推荐答案

过滤器的代码可能如下所示

The code of the filter could be like the following

customSortOperations: {
    lne: {
        operand: "<!=''",
        text: "less but not empty",
        filter: function (options) {
            var v = options.item[options.cmName];

            if (v !== undefined && v !== "" &&
                    parseFloat(v) < parseFloat(options.searchValue)) {
                return true;
            }
        }
    }
}

请参阅修改后的演示 https://jsfiddle.net/OlegKi/x3fger4z/17/

这篇关于Free-jqgrid 4.15.4中的自定义过滤器记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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