Kendo Grid JSON数据源绑定

时间:2015-07-09 11:11:02

标签: json kendo-ui kendo-grid

我似乎在试图将我的JSON结果发送到我的Kendo UI网格

时出现问题

这是我从我的网络服务回来的JSON结果:

"{
    "Data":[{
        "ModifiedBy":"Joe Blogs",
        "ModifiedDate":"2015-04-27T00:00:00",
        "Name":"One",
        "Number":"201504260952",
        "Status":"Draft",
        "Id":3
    },
    {
        "ModifiedBy":"Joe Blogs",
        "ModifiedDate":"2015-07-08T11:04:00",
        "Name":"fdasfdsa",
        "Number":"20150708110209",
        "Status":"Draft",
        "Id":17},
    {
        "ModifiedBy":"Joe Blogs",
        "ModifiedDate":"2015-07-09T08:44:00",
        "Name":"Two",
        "Number":"20150709084329",
        "Status":"Draft",
        "Id":20
    }],
    "Groups":null,
    "Total":3
}"

这是我的网格和数据源设置:

$(function () {
        var myGrid = $("#myGrid");
        myGrid.kendoGrid({
            groupable: true,
            sortable: true,
            filterable: true,
            pageable: {
                refresh: true,
                pageSizes: true,
                buttonCount: 5
            },
            columns: [{
                hidden: true,
                field: "Id"
            },
            {
                headerTemplate: ""
            },
            {
                title: "Status",
                field: "Status"
            },
            {
                title: "Number",
                field: "Number"
            },
            {
                title: "Name",
                field: "Name"
            }]
        });

        var myDataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "/somewhere.svc/Data",
                    dataType: "json",
                    type: "GET"
                }
            },
            schema: {
                data: 'Data',
                groups: 'Groups',
                aggregates: 'Aggregates',
                total: 'Total',
                model: {
                    id: 'Id',
                    fields: {
                        Id: { type: 'number' },
                        Status: { type: 'string' },
                        Number: { type: 'string' },
                        Name: { type: 'string' },
                        ModifiedBy: { type: 'string' },
                        ModifiedDate: { type: 'date' }
                    }
                }
            },
            pageSize: 5,
            serverPaging: true,
            serverGrouping: true,
            serverSorting: true,
            serverFiltering: true
        });

        myGrid.data("kendoGrid").setDataSource(myDataSource);
    });

当页面加载时,我可以看到我得到了上面的JSON,但我没有在网格中显示任何行。

我可能做错了什么?

0 个答案:

没有答案