views:

368

answers:

3

I have a dojo dijit.Tree, and I want to be able to put some html in the labels. To do this, I created an function called getCustomLabel and assigned it to the tree getLabel attribute:

tree = new dijit.Tree({
                model: aMOdel,
                showRoot: false,
                getLabel: getCustomLabel
            });

function getCustomLabel(item) {
    return '<b>'+item.name+'</b>'
}

This returns a Tree with the html escaped so that it displays in the tree. Does anyone know of a way to get unescaped html in a tree widget?

A: 

Wouldn't unescape() achieve this?

function getCustomLabel(item) {  
    item.name = unescape(item.name);  
    return '<b>'+item.name+'</b>';  
}
jakeisonline
The escaping is happening after the "getCustomLabel()" returns it's value.
jbella
It would be good to see the actual page or more extensive code
jakeisonline
A: 

There is a very simple way actually :)

Right after the dojo.require statement add the following:

dojo.require("dijit.Tree");
dijit._TreeNode.prototype.setLabelNode = function (label) {
        this.labelNode.innerHTML = label;
};
Erdem Memisyazici
A: 

This code dont' work in my tree((( I want to create tree with HTML-tags, but my tree shows tags as text. Help,please, what must I do?

RRR