gpt4 book ai didi

Javascript Kendo Grid "Cannot read property ' length' of null"错误

转载 作者:行者123 更新时间:2023-11-28 04:17:31 26 4
gpt4 key购买 nike

我有一个可扩展的剑道网格,它从按不同实体分组的两个存储过程返回数据。但是,它仅返回三个实体之一的有效负载列中的数据。在开发人员控制台中调试时,它返回“无法读取 null 的属性‘长度’”。我已经评论了似乎导致错误的代码行。我不确定为什么它只会对三个实体值之一执行此操作,但想知道是否有人提出修复建议,因为我是初学者。请告诉我,谢谢!

function InitiateGrid(e) {        
var grid = e.detailRow.find(".entityDetail").kendoGrid({
dataSource: {
type: "json",
transport: {
read: function (option) {
$.ajax({
contentType: "json",
url: "/Test.svc/json/GetDetail",
success: function (result) {
option.success(result.Response); //error happening within this line of code
},
error: function (result) {
option.error(result.Response);
},
data: {
entityId: function () { return $("#txtEntityId").val(); },
entityTypeName: function () { return $("#txtEntityType").val(); }
}
});
}
},
schema: {
model: {
fields: {
Number: { type: "string", editable: false, nullable: true },
Id: { type: "string", editable: false },
}
}
},
},
scrollable: true,
sortable: true,
pageable: false,
selectable: "row",
columns: [
{
filterable: false,
title: "Number",
field: "Number",
width: 25,
},
{
filterable: false,
field: "Id",
title: "Id",
width: 25,
}
]
});
}

最佳答案

您不需要在 Kendo Data Source 中另一个 Ajax 请求.

transport: {
read: {
url: "/Test.svc/json/GetDetail",
type: "get",
dataType: "json",
data: {
entityId: function () { return $("#txtEntityId").val(); },
entityTypeName: function () { return $("#txtEntityType").val(); }
}
},

关于Javascript Kendo Grid "Cannot read property ' length' of null"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45699498/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com