我正在尝试调用web api方法并将此数据返回到kendo网格并在我的网格中显示此数据。从我的web api方法返回的模型具有包含其他对象的导航属性,我只是尝试使用kendo模板在我的网格中显示这些导航元素。但是,我遇到了无法检测到导航属性存在的问题,即使我在调试时可以看到它。
//schema for my kendo data source
schema: {
data: function (data) { //specify the array that contains the data
console.log("This object has a FREQ_POOL object, and it contains data");
console.log(data);
var tmp = [{ FREQ_POOL: { IsAM: 'Jane', last: 'Doe' } }, { FREQ_POOL: { IsAM: "John", last: 'Doe' } }];
console.log("This object has the same structure and is manually created, and it works if I return it from her in my grid);
console.log(tmp);
//return tmp; THIS WORKS
return data; This throws the error FREQ_POOL is undefined
},
}
......................................................
$("#FAAFreqGrid").kendoGrid({
dataSource: FAADS,
columns: [
{ field: "FREQ_POOL", template: "<strong>#: FREQ_POOL.IsAM# </strong>", title: "FAATEST", format: "{0:c}", width: "120px" },
{ command: ["edit", "destroy"], title: " ", width: "250px" }
],
toolbar: ["create"],
editable: "inline",
pageable: true
});
当我查看console.logs返回的对象时,它们在结构上看起来完全相同。两者都有一个带有IsAM集的FREQ_POOL。但如果我返回“数据”而不是“tmp”,我会收到错误
`"Uncaught ReferenceError: FREQ_POOL is not defined"`.
因此,出于某种原因,即使两个对象看起来都相同,也没有在“数据”中检测到FREQ_POOL,但是在“tmp”中