简体   繁体   中英

How to set a css class for a selected node in a tree?

I am using a Dijit Tree, and I need to change the CSS style for a node when selected (focus). Lets imagine a node is black when "deselected", and it becames red when "selected" and viceversa.

What should I change in my code?

var tree = new Tree({
                model: this._model,
                showRoot: true,
                autoExpand: true,
                persist: false,
                getLabel: function (item) {
                    return item.name;
                },
                onClick: function (item, node, event) {
                    businessLogic.goToView(item.id);
                }

如果要更新所选节点的css,则应像这样覆盖css: .claro .dijitTreeRowSelected { color: red }这是一个简单的jsfiddle,它将使所选标签变成红色,并将鼠标悬停在一个绿色上: http ://jsfiddle.net/edchat/dox42qye/15/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM