How to set the tree view node color for Kendo UI T

2019-08-09 06:52发布

I want to set the tree view color based on the value defined in the datasource field,

From this link, I think that what I am trying to do is possible, but I am not using MVVM, so in my case what I am missing below? any idea??

http://www.telerik.com/forums/mvvm---treeview-only-updates-on-datatextfield-change

<div id="treeview"></div>

$("#treeview").kendoTreeView({
  template: "#= item.text # color:#: item.color #",
  dataSource: [
    { text: "green", color: "green", items: [
      { text: "yellow", color: "yellow" },
      { text: "red", color: "red" }
    ]},{
    text: "blue", color: "blue"
    }
  ]
});

Fiddle link, http://jsfiddle.net/KendoDev/qZeK6/

1条回答
闹够了就滚
2楼-- · 2019-08-09 07:28

Define the template as:

    template: "<span style='color: #= item.text #'>#= item.text # color:#: item.color #</span>",

As far as the color is valid color name it should work.

Your JSFiddle modified here: http://jsfiddle.net/OnaBai/qZeK6/3/

查看更多
登录 后发表回答