KendoUI。下拉列表的虚拟化无法正常工作

时间:2017-07-04 09:10:56

标签: kendo-ui dropdown

我尝试使用服务器过滤和分页进行下拉列表。分页工作正常,但是当我开始输入过滤器时,我的控件会向服务器发送无限次查询。请帮我配置这个控件。 数据源:

select id, class, name from student;

下拉选项:

getDataSource = function () {
        return new kendo.data.DataSource({
            type: "json",
            transport: {
                read:{
                    url:"...",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json"
                },
                parameterMap: function (options, operation) {
                    switch (operation) {
                        case "read":
                            return JSON.stringify(options);
                            break;
                    }
                }
            },
            schema: {
                data: "Data",
                total: "Total",
                model: {
                    id: "Id"
                }
            },
            pageSize: 20,
            serverPaging: true,
            serverFiltering: true
        });
    }

和服务器端:

$scope.DropDownOptions = {
        dataTextField: "Value",
        dataValueField: "Id",
        dataSource: getDataSource(),
        filter: "contains",
        virtual: {
            itemHeight: 26,
            valueMapper: function (options) {
                $.ajax({
                    url: "...",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    data: JSON.stringify({
                        skip: 0, pageSize: 20, take: 1, filter: { logic: "and", filters: [{ value: options.value, field: "Value", operator: "contains", ignoreCase: true }] }
                    }),
                    success: function (data) {
                        options.success([]);
                    }
                })
            }
        },
        height: 290,
    }

更重要的是: 当我改变 options.success([])到options.success(data.Data),它仍然发送无限查询,但另外在第一项中有分层(2个相同的值在一个容器中绘制),并且分页正在减慢。当我滚动列表一点时,分页规范化

1 个答案:

答案 0 :(得分:0)

问题解决了。这种奇怪的行为是由 response.Total = 1000; 我需要在这个字段中写入数据库中的实数

相关问题