PDA

View Full Version : selecting the Tree node



mango
11 Nov 2009, 8:01 AM
Hi,

I am trying to highlight a node in the rendered tree. I have node id and I used the following code to highlight the node:

tree.render();
tree.expandAll();
if(tree.getNodeById(<node-id>)) {
tree.getNodeById(<node-id>).ensureVisible();
tree.getNodeById(<node-id>).select();
}

Tree is rendered and all nodes expanded but the particular node is not highlighted.

where I am going wrong?

Thanks,
Sri

Animal
11 Nov 2009, 8:18 AM
If it's working right, it should add the class "x-tree-selected" to the node's DIV element.

Check that.

After that, it's just a matter of CSS rules.

mango
11 Nov 2009, 9:30 AM
It is not working right!

--Sri

Ash2009
11 Nov 2009, 2:15 PM
u can try highlighting by applying CSS class


tree.render();
tree.expandAll();

if(tree.getNodeById(<node-id>)) {
var n = tree.getNodeById(<node-id>);
n.ensureVisible();
n.getUI().addClass('highlight-node');
}




/*in CSS */
.highlight-node .x-tree-node-anchor span{
background-color: yellow !important;
}