Kendo Grid Object不支持属性或方法' slice'

时间:2015-08-19 19:26:47

标签: jquery ajax json kendo-ui

我正在尝试将kendo网格绑定到WCF远程odata服务。但是当我尝试填充网格时,我收到异常对象不支持属性或方法' slice' 。这是我填充网格的javascript代码。

$("#datagrid").kendoGrid({
                dataSource: {
                    type: "json",
                    transport: {
                        read: "http://localhost:65401/sdrservice.svc/IssueLists"
                    },                    
                    pageSize: 20
                },                
                groupable: true,
                sortable: true,
                pageable: {
                    refresh: true,
                    pageSizes: true,
                    buttonCount: 3
                },
                columns: [{                  
                    field: "Issueid"                                        
                }, {
                    field: "Subject"                    
                }, {
                    field: "Description"
                }, {
                    field: "Module"                   
                }, {
                    field: "Status"
                }, {
                    field: "StartDate"
                }, {
                    field: "ClosureDate",
                    nullable: true
                }, {
                    field: "RaisedBy"
                }, {
                    field: "Duration"
                }]
            });

我的json对象就像

    {"odata.metadata":"http://localhost:65401/sdrservice.svc/$metadata#IssueLists",
"value":[{"Issueid":"512","Subject":"Crossing","Description":"a feugiat et eros vestibulum ac est lacinia nisi venenatis tristique fusce congue diam id ornare imperdiet","Module":"ADF","Status":"Fixed","StartDate":"2013-05-14T00:00:00","ClosureDate":null,"RaisedBy":"Azhar Husain","Duration":828},
    {"Issueid":"474","Subject":"Point","Description":"a feugiat et eros vestibulum ac est lacinia nisi venenatis tristique fusce congue diam id ornare imperdiet sapien urna","Module":"ADF","Status":"Open","StartDate":"2012-10-09T00:00:00","ClosureDate":null,"RaisedBy":"Azhar Husain","Duration":1045},
    {"Issueid":"937","Subject":"Point","Description":"a ipsum integer a nibh in quis justo maecenas rhoncus aliquam lacus morbi","Module":"TM1","Status":"Fixed","StartDate":"2013-05-31T00:00:00","ClosureDate":null,"RaisedBy":"Azhar Husain","Duration":811},
    {"Issueid":"226","Subject":"Point","Description":"a libero nam dui proin leo odio porttitor id consequat in consequat","Module":"DATA MINING","Status":"Open","StartDate":"2014-11-08T00:00:00","ClosureDate":null,"RaisedBy":"Azhar Husain","Duration":285},
    {"Issueid":"76","Subject":"Hill","Description":"a libero nam dui proin leo odio porttitor id consequat in consequat ut nulla sed","Module":"TM1","Status":"Fixed","StartDate":"2013-04-12T00:00:00","ClosureDate":null,"RaisedBy":"Azhar Husain","Duration":860}]}

我认为问题是json对象作为slice方法需要数组,这里是data.value但是如何使用它是我的问题,因为方法中的read line直接调用服务并执行所需的任务我无法控制它

2 个答案:

答案 0 :(得分:2)

您需要设置dataSource的schema.data属性。

schema: {
  data: 'value'
}

文档http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.data

答案 1 :(得分:0)

您需要在配置中设置schema,因为您不是将数据源直接绑定到返回的对象,而是实际绑定到该对象中的属性(即{{1} } property。。

尝试像这样设置数据源:

value