Kendo TreeView显示未定义

问题描述 投票:0回答:1

我有这个示例剑道树视图演示,如果我使用相同的名称,它可以正常工作,但是当我使用不同的名称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"}
  ]
});
jquery kendo-ui kendo-grid kendo-treeview
1个回答
1
投票

您只需要模板中的条件语句。这样的事情应该可以做到:

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

© www.soinside.com 2019 - 2024. All rights reserved.