1
votes

This is my code:

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'
});

But when i try to click on "page two", parameters "skip" and "pageSize" not transmitted. I getting this url "/admin/list" without parameters. What i doing wrong?

1
This is my fail. parameterMap: function (options, operation) { if (operation !== "read" && options.models) { return {models: kendo.stringify(options.models)}; } } i delete this construction and all is workСаня Григорь

1 Answers

2
votes

I think your parameterMap function needs to return something for the case where operation === "read":

        parameterMap: function (options, operation) {
            if (operation !== "read" && options.models) {
                return {models: kendo.stringify(options.models)};
            }
            return options; // <-- added this line
        }