Kendo UI网格绑定错误

时间:2015-02-02 07:16:56

标签: javascript jquery kendo-ui kendo-grid

我正在使用kendo UI网格,这是我的代码

JAVASCRIPT

 $("#logs").kendoGrid({
                    dataSource: {
                        type: "json",
                        transport: {
                            read: {
                                url: "https://localhost:1153/v3.svc/auditlog",
                                dataType: "json",
                                data: '?&tableName=' + table + '&userId=' + userId + '&fromDate=' + dateFrom + '&toDate=' + dateto + '&isSearchForClient=' + true,
                                type: "GET",
                                contentType: "application/json; charset=utf-8"
                            }
                        },
                        pageSize: 10, //page size
                        schema: {
                            data: "d", //root element that contains data array
                            total: "d.length" //total amount of records
                        }
                    },
                    pageable: true, //enable paging
                    columns: [{ field: "d.TransactionId", title: "TransactionID", width: "30px" }, { field: "d.Log", title: "Audit Logs", width: "110px" }]
                });

来自服务器的是什么呢?

[ { "TransactionId" : "185492010250010630", "Log" : "Administrator  Super has updated jobdescmanagement on 1/28/2015 4:24:03 PM"}]

它在控制台中给出的错误是

Uncaught Sys.ParameterCountException: Sys.ParameterCountException: Parameter count mismatch.

1 个答案:

答案 0 :(得分:0)

根据您的JSON数据结构字段配置应

columns: [{
    field: "TransactionId",
    title: "TransactionID",
    width: "30px"
}, {
    field: "Log",
    title: "Audit Logs",
    width: "110px"
}]

在这种情况下,您不需要schema配置,因为您没有根JSON元素。

架构

schema: {
    data: "d"
}

表示数据具有以下格式:

{d: [{"TransactionId": "185492010250010630", "Log": "Administrator Super has updated jobdescmanagement on 1/28/2015 4:24:03 PM"}]}

然而,这不是你的情况。