How to set the tree view node color for Kendo UI TreeView?

大憨熊 提交于 2019-12-11 10:08:29

问题


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:


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/



来源:https://stackoverflow.com/questions/25086392/how-to-set-the-tree-view-node-color-for-kendo-ui-treeview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!