剑道 UI 网格绑定错误

Kendo UI grid binding error

本文关键字:错误 绑定 网格 UI 剑道      更新时间:2023-09-26

我正在使用剑道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"}]}

但是,这不是您的情况。