Anil Vishnoi
Anil Vishnoi

Reputation: 1392

How to change color of specific tree node of the dojo tree

I created one dojo tree as follows :

store = new dojo.data.ItemFileWriteStore({url: link});
treeModel = new dijit.tree.TreeStoreModel({
                                        store: store,
                                        query: {
                                                "type": "ROOT"
                                                },
                                        rootId: "newRoot",
                                        childrenAttrs: ["children"]
                                    });

new dijit.Tree({model: treeModel},"treeOne");

Here this url points to one json file. I am adding node to this tree dynamically as follows :

store.fetchItemByIdentity({
                       identity: pid,
                       onItem : function(item, request) {
                       parentitem = item;
                       treeModel.newItem({id: cid,name: cname,type: ctype},parentitem)
                       },
                      onError : function(item, request) {
                      }
                   });
                 }

While adding these new entry as a tree node to this tree,i want to change the color of some tree nodes to red or some other color,just to differentiate from other nodes just for users attention. Is there any way this can be done in the dijit tree? Changing the background color is not the only option,i just want to display that node a bit differently so that user can notice that node. Any help??

Upvotes: 0

Views: 2808

Answers (1)

neil
neil

Reputation: 76

Sorry I think the answer is too late, but until a couple of months ago I didn't start working with dojo. Maybe this snippet can help you. It allows to change the text color of the current selected node:

var node = dijit.byId('layerTree').selectedNode;
if(!node) return;

if(value) {
    node.labelNode.style.color = "black";
}else {
    node.labelNode.style.color = "#ddd";
}

Upvotes: 2

Related Questions