Kendo UI 网格绑定错误
Kendo UI grid binding error
我正在使用 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.
根据你的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"}]}
然而这不是你的情况。
我正在使用 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.
根据你的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"}]}
然而这不是你的情况。