Вопрос

take a look at these 2 fiddles

http://jsfiddle.net/uFcHK/ (v2013.1.319)

http://jsfiddle.net/rcvY3/ (v2013.2.716)

The code is identical.

var grid = $("#grid").kendoGrid({
    dataSource: {
        type: "odata",
        transport: {
            read: "http://demos.kendoui.com/service/Northwind.svc/Products"
        },
        pageSize: 15,
        serverPaging: true,
        serverSorting: true,
        serverFiltering: true
    },

    height: 450,
    sortable: true,
    pageable: true,
    editable: true,
    toolbar: ["create"],
    filterable: false,
    columns: ["ProductID", "ProductName", "UnitPrice"]
});

(you can ignore the the broken nav panel, I don't see this in prod)

The problem is the record count.

If you click on "Add new record" you will see the record count do a text add instead of number add. This is crazy, no idea how kendo let this slide for half a year+

Это было полезно?

Решение

The problem is with OData that return total as string since this is received as string.

In previous releases of code the increment was done as total++ but now it is being added a number allowing to add more than one record in one single operation. The problem is that if you do string + number you actually get the number concatenated to the string.

The easiest way of solving it is providing a total function that just converts the string to number something as simple as defining in the DataSource:

dataSource: {
    type           : "odata",
    transport      : {
        read: "http://demos.kendoui.com/service/Northwind.svc/Products"
    },
    schema : {
        total : function (data) {
            // Convert __count to number
            return +data.d.__count;
        }
    },
    pageSize       : 15,
    serverPaging   : true,
    serverSorting  : true,
    serverFiltering: true
},
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top