问题
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