Kendo UI网格过滤列具有多个值 [英] Kendo UI Grid Filtering column with multiple values

查看:66
本文介绍了Kendo UI网格过滤列具有多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用过滤器在我的KendoUI网格上成功搜索.但是,新应用程序的某些字段具有多个值,因此我的过滤不起作用-它实际上似乎永远旋转.

I have been using filters to successfully search on my KendoUI grids. However a new application has some fields that are multi-valued and my filtering doesn't work - it actually just seems to spin forever.

多值字段的示例:

field   : "rspPersons",
title   : "Responsible Persons",
type    : "Text",
template: "# var t=rspPersons.join(', ');data.tagsString=t; # #=t #"

我的过滤器示例:

                        orfilter.filters.push( {
                            field : "chgDescription",
                            operator : "contains",
                            value : v1
                        },
                        orfilter.filters.push( {
                            field : "rspPersons",
                            operator : "contains",
                            value : v1
                        } 

第二个过滤器将使整个搜索分解.如果我将其取出,那么搜索/过滤器就可以正常工作.

The second filter will make the entire search break down. If I take it out, then the search/filter works just fine.

那么如何过滤/搜索多值字段?

So how can I filter/search on multi-value fields?

推荐答案

您需要将多个过滤条件推入过滤器数组,并将其分配给Grid的数据源.这是我的工作方式.

You'll need to push multiple filter criteria into filter array and assign it to the of Grid's datasource. Here's how I have done.

function onChange() {
    var filter = { logic: "or", filters: [] };
    //  values is an array containing values to be searched
    var values = this.value();
    $.each(values, function (i, v) {
        filter.filters.push({ field: "column_name", operator: "eq", value: v 
       });
    });
    var dataSource = $("#searchgrid").data("kendoGrid").dataSource;
    dataSource.filter(filter);
}

这篇关于Kendo UI网格过滤列具有多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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