问题
I am trying to call a web api method and return this data to a kendo grid and display this data in my grid. The model that is returned from my web api method has navigation properties that have other objects, and I am just trying to display these navigation elements in my grid using a kendo template. However, I am having problems with it not being able to detect that the navigation property exists, even though I can see it when I debug.
//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
});
When I look at the objects both console.logs return, they look identical in structure. Both have a FREQ_POOL with an IsAM set. But if I return "data" instead of "tmp", I get the error
`"Uncaught ReferenceError: FREQ_POOL is not defined"`.
So for some reason even though both objects look identical, FREQ_POOL is not being detected in "data", but is in "tmp"
来源:https://stackoverflow.com/questions/29015105/kendo-grid-child-navigation-binding-issues