如何设置Kendo UI TreeView的树视图节点颜色? [英] How to set the tree view node color for Kendo UI TreeView?

查看:343
本文介绍了如何设置Kendo UI TreeView的树视图节点颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据数据源字段中定义的值设置树状视图的颜色

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

通过此链接,我认为我可以做的事情是可能的,但是我没有使用MVVM,因此,就我而言,我在下面缺少什么?有什么想法吗?

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"
    }
  ]
});

小提琴链接, http://jsfiddle.net/KendoDev/qZeK6/

推荐答案

将模板定义为:

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

只要color是有效的颜色名称,它就应该起作用.

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

您的JSFiddle在此处进行了修改: http://jsfiddle.net/OnaBai/qZeK6/3/

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

这篇关于如何设置Kendo UI TreeView的树视图节点颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆