【问题标题】:Kendo-UI datasource "contains" filter not workingKendo-UI 数据源“包含”过滤器不起作用
【发布时间】:2014-08-11 23:07:44
【问题描述】:

我似乎无法在多选数据源中使用“包含”过滤器运算符进行过滤。我正在使用 AngularJS 并提供一个示例,我在 Telerik 演示站点上修改了 MultiSelect 示例。即使我指定了“包含”,它也使用“starts-with”进行过滤:

angular.module("KendoDemos", ["kendo.directives"]);

function MyCtrl($scope) {
    $scope.selectOptions = {
        placeholder: "Select products...",
        dataTextField: "ProductName",
        dataValueField: "ProductID",
        autoBind: false,
        dataSource: {
            type: "odata",
            serverFiltering: false,
            filter: {
                field: "ProductName",
                operator: "contains"
            },
            transport: {
                read: {
                    url: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Products",
                }
            }
        }
    };
    $scope.selectedIds = [4, 7];
}

演示:http://jsbin.com/riwavomeleza/1/edit

【问题讨论】:

    标签: javascript kendo-ui kendo-datasource angular-kendo kendo-multiselect


    【解决方案1】:

    您要指定小部件的过滤行为,而不是数据源过滤器,因此您需要为多选小部件使用filter 选项:

    angular.module("KendoDemos", ["kendo.directives"]);
    
    function MyCtrl($scope) {
        $scope.selectOptions = {
            placeholder: "Select products...",
            dataTextField: "ProductName",
            dataValueField: "ProductID",
            autoBind: false,
            filter: "contains",
            dataSource: {
                type: "odata",
                serverFiltering: false,
                transport: {
                    read: {
                        url: "...",
                    }
                }
            }
        };
        $scope.selectedIds = [4, 7];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-20
      • 1970-01-01
      • 2012-11-14
      • 2018-02-27
      • 1970-01-01
      相关资源
      最近更新 更多