我有这个示例剑道树视图演示,如果我使用相同的名称它可以正常工作,但是当我使用不同的名称时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] 删除。
我来说两句