Kendo-UI数据源“包含”过滤器无法正常工作

时间:2014-08-11 23:07:45

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

我似乎无法过滤使用多选数据源中的“包含”过滤器运算符。我正在使用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

1 个答案:

答案 0 :(得分: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];
}