kendo-uikendo-gridkendo-treeview

Kendo TreeView template text color


I want to set the treeview to color red if active='n' based on the value defined in the datasource field. How to achieve this? 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>

Solution

  • You can apply the condition to style attribute in template property as below,

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

    working example here