Kendo UI 网格 - 绑定到导航属性

Kendo UI Grid - Binding to navigation properties

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

  //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

        });

如果我访问我的网站 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 未定义。我无法将其绑定到任何 属性 我可以绑定到任何其他非导航字段。我如何使这项工作?数据存在于返回的 JSON 对象中,但绑定无法正常工作。谢谢

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

$("#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