PDA

View Full Version : Single click expand tree nodes



catapult
11 May 2010, 12:51 AM
How do I go about making the nodes in my tree expand on a single click? I have looked at the API and Ext.tree.TreeNode has the property "singleClickExpand" but I'm not sure how to implement this.

This is the code for my tree:



var TREE = new Ext.tree.TreePanel({
id : 'treepanel',
title : 'Categories',
width : 160,
height : 400,
frame : false,
border : true,
autoScroll : true,
useArrows : true,
singleExpand : true,
animate : true,
enableDD : false,
rootVisible : false,
containerScroll : true,
dataUrl : 'get-nodes.php',
root : {
nodeType : 'async',
text : 'Catalogue',
draggable : false,
id : 'src'
},
listeners : {
'click' : function(n){
OPTIONS.load({params:{id:n.attributes.id}});
Ext.getCmp('centreRegion').setTitle(n.attributes.text);

Ext.getCmp('ItemDetails').hide();
OPTIONS_DATAVIEW.show();
},
'expandNode' : function(n){
OPTIONS.load({params:{id:n.attributes.id}});
Ext.getCmp('centreRegion').setTitle(n.attributes.text);
},
'collapseNode' : function(n){
OPTIONS.load({params:{id:'src'}});
Ext.getCmp('centreRegion').setTitle('Catalogue');
}
}
});


Many thanks

gevik
11 May 2010, 4:28 AM
Make sure the JSON returning from get-nodes.php contains the singleClickExpand set to true for each (folder) node it returns.

I hope this helps.

fabio.parra
11 May 2010, 4:34 AM
Hi...it seems that you need add property "singleClickExpand" for each node:


{
text : "adapter",
singleClickExpand : true,
cls : "folder",
}

catapult
11 May 2010, 7:26 AM
Thanks guys that's solved my problem.

aconran
11 May 2010, 8:23 AM
You could also use the baseAttrs configuration to add singleClickExpand to all tree nodes.