Kendo TreeView 显示未定义

Kendo TreeView display undefined

我有这个示例 kendo treeview 演示,如果我使用相同的名称它工作正常但是当我使用不同的名称时 ledger/group 它显示为 undefined。知道如何解决这个问题吗?

Full demo here

$("#treeview").kendoTreeView({
  dataBound: function(){
   this.expand('.k-item');
  },
  template: "<span #if(item.active=='n'){# style='color:red' #} #>#:item.group#</span>" ,
  dataSource: [
    { ledger: "Title 1st", active:"y", items: [
      { group: "subTitle1", active:"y" },
      { group: "subTitle2", active:"n" },
      { group: "subTitle3", active:"y" },
      ]},{
    ledger: "Title 2nd", active:"n"}
  ]
});

您只需要在模板中加入条件语句。应该这样做:

$("#treeview").kendoTreeView({
  dataBound: function(){
    this.expand('.k-item');
  },
  template: "<span #if(item.active=='n'){# style='color:red' #} #>#: item.group != null ? item.group : item.ledger #</span>" ,
  dataSource: [
    { ledger: "Title 1st", active:"y", items: [
      { group: "subTitle1", active:"y" },
      { group: "subTitle2", active:"n" },
      { group: "subTitle3", active:"y" },
    ]},{
      ledger: "Title 2nd", active:"n"}
  ]
});

Full demo here