【问题标题】:Kendo TreeView template text colorKendo TreeView 模板文本颜色
【发布时间】:2019-09-11 04:21:34
【问题描述】:

如果active='n' 基于数据源字段中定义的值,我想将树视图设置为红色。如何做到这一点? Demo in Dojo

$("#treeview").kendoTreeView({
 // template: "#if(item.active=='n'){# <span style='color:red'></span>  #} #" ,
  dataSource: [
  { text: "Title 1st",  items: [
  { text: "subTitle1", active:"y" },
  { text: "subTitle2", active:"n" },
  { text: "subTitle3", active:"y" },
  ]},{
  text: "Title 2nd"
  }
  ]
});
<div id="treeview"></div>

【问题讨论】:

    标签: kendo-ui kendo-grid kendo-treeview


    【解决方案1】:

    您可以将条件应用于模板属性中的样式属性,如下所示,

    template: "<span #if(item.active=='n'){# style='color:red' #} #>#:item.text#</span>"
    

    工作示例here

    【讨论】:

    • 嗨@Paulraj,我知道这个帖子已经有 2 周了,我需要你的帮助。知道为什么在我更改父母姓名后它显示未定义吗? dojo.telerik.com/aqOtEjIc
    • @Nixoderm 属性名称应同名,无论其父项还是子项。如果您想使用LedName,请将所有accName 替换为LedName。检查这个dojo
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多