剑道UI网格。未传输参数 - pageSize和Skip

时间:2013-09-10 06:41:34

标签: json kendo-ui kendo-grid

这是我的代码:

var crudServiceBaseUrl = "/admin",
    dataSource = new kendo.data.DataSource({
        serverPaging: true,
        pageSize: 2,
        type: 'json',
        transport: {
            read: {
                url:  crudServiceBaseUrl + '/user'
            },
            update: {
                url: function (item) {
                    return crudServiceBaseUrl + "/user/update/" + item.id
                },
                dataType: "json"
            },
            destroy: {
                url: crudServiceBaseUrl + "/user/destroy",
                dataType: "json"
            },
            create: {
                url: crudServiceBaseUrl + "/user/create",
                dataType: "json"
            },
            parameterMap: function (options, operation) {
                if (operation !== "read" && options.models) {
                    return {models: kendo.stringify(options.models)};
                }
            }
        },
        batch: true,
        schema: {
            data: function (rawData) {
                return rawData[0].data;
            },
            total: function (rawData) {
                return rawData[1].total;
            }
        }
    });
$("#users").kendoGrid({
    dataSource: dataSource,
    navigatable: true,
    pageable: true,
    selectable: "multiple",
    sortable: {
        mode: "single",
        allowUnsort: false
    },
    height: 430,
    toolbar: ["save", "cancel"],
    columns: [
        { field: "id", title: "ID", width: 20},
        { field: "username", title: "E-mail", width: 110 },
        { field: "firstname", title: 'firstname', width: 110 },
        { field: "lastname", title: 'lastname', width: 110 },
        { field: "activated", title: 'Activated', width: 110 },
        { field: "disabled", title: 'Disabled', width: 110 },
        { command: ['edit', 'destroy'], title: " ", width: 90 }
    ],
    editable: 'popup'
});

但是当我尝试点击“第二页”时,参数“skip”和“pageSize”没有被传输。我得到这个网址“/ admin / list”没有参数。我做错了什么?

1 个答案:

答案 0 :(得分:1)

我认为parameterMap函数需要为operation === "read"

的情况返回一些内容
        parameterMap: function (options, operation) {
            if (operation !== "read" && options.models) {
                return {models: kendo.stringify(options.models)};
            }
            return options; // <-- added this line
        }