剑道树视图显示未定义

不要再被禁止

我有这个示例剑道树视图演示,如果我使用相同的名称它可以正常工作,但是当我使用不同的名称时ledger/group它读取为undefined. 知道如何解决这个问题吗?

完整演示在这里

$("#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"}
  ]
});

完整演示在这里

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章