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