gpt4 book ai didi

javascript - Kendo UI 网格 - 绑定(bind)到导航属性

转载 作者:行者123 更新时间:2023-12-03 10:35:36 26 4
gpt4 key购买 nike

我正在使用 Kendo UI 网格并显示模型的 Angular 色。每个模型都有一个导航属性,我正在尝试显示此导航属性中存在的字段。

  //schema for my kendo data source
schema: {
data: function (data) {
return data || [];
}
}
......................................................
$("#FAAFreqGrid").kendoGrid({
dataSource: FAADS,

columns: [
{ field: "Id", title: "Freq ID", format: "{0:c}", width: "120px" },
{ field: "Frequency", title: "Frequency Test" format: "{0:c}", width: "120px" },
{ field: "FREQ_POOL", title: "FAATEST", format: "{0:c}", width: "120px" },
{ command: ["edit", "destroy"], title: " ", width: "250px" }
],
toolbar: ["create"],
editable: "inline",
pageable: true

});

如果我访问我的 Web API Url,我会收到以下 json 响应:

[{"$id":"1","Frequency":"164.1375","FREQ_POOL":{"$id":"2","IsAM":true,......etc}

FREQ_POOL 是我的导航属性,它有我想要的数据。频率存在并正确显示在我的网格中。但我的 FREQ_POOL 字段显示 [object Object],如果我尝试说“FREQ_POOL.IsAM”,它会显示 IsAM 未定义。我无法将其绑定(bind)到我可以绑定(bind)到任何其他非导航字段的任何属性。我该如何进行这项工作?数据存在于返回的 JSON 对象中,但绑定(bind)无法正常工作。谢谢。

最佳答案

您可以为相关列设置一个模板,如下所示:

$("#grid").kendoGrid({
columns: [ {
field: "name",
template: "<strong>#: name.first#, #: name.last# </strong>"
}],
dataSource: [ { name: { first: 'Jane', last: 'Doe' } }, { name: { first: "John", last: 'Doe' } } ]
});

然后可以使用模板来显示数据集中的对象

更多信息,您可以找到here

对于编辑,您还可以定义单元格编辑器,使用额外的模板或函数,有关更多信息,您可以找到 here .

关于javascript - Kendo UI 网格 - 绑定(bind)到导航属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28998383/

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