View Full Version : Setting selectednode during exand events

13 Aug 2010, 6:42 AM
Hi all,

You can expand the tree panel without selecting a node by clicking the plus(+) sign (or the arrows). This results in a null if you try to get the node from the model at that time (although, oddly, you can get the node id from cgi parameters). I would like to set the selected node to the same node of which the plus sign was clicked - does anyone have any idea how to do that? Here is my base code:


var Tree = Ext.tree;

var tree = new Tree.TreePanel({
expandable: false,
autoScroll: true,
animate: true,
enableDD: false,
singleExpand: true,
containerScroll: true,
border: false,
// auto create TreeLoader
dataUrl: 'get-nodes.pl',
root: {
nodeType: 'async',
text: 'Dashboards:',
draggable: false,
id: 'src'
buttons: [{
text: 'Show Path Information',
handler: function(){
var model = tree.getSelectionModel();
var msg = '', selNodes = model.getSelectedNode().getPath();
Ext.each(selNodes, function(nodeId){
if(msg.length > 0){
msg += ', ';
msg += nodeId;
title: 'Path to Root',
msg: msg.length > 0 ? msg : 'None',
icon: Ext.Msg.INFO,
minWidth: 200,
buttons: Ext.Msg.OK

// render the tree

13 Aug 2010, 8:06 AM
Figured it out - just added this to my treepanel:

listeners: {
beforeexpandnode: function(node, d, a) {
root: {