PDA

View Full Version : Ext.Tree.Panel auto open first leaf.



shakerkk
9 Oct 2014, 1:21 AM
I dont know how to explain very good but i want to ask if is possible to configure my tree when is loaded to auto open my first leaf from first root .
Thank you.

watertrac_dev
9 Oct 2014, 5:51 AM
Do you mean you'd like to expand the first node below the root?

bi3

shakerkk
9 Oct 2014, 6:07 AM
Yes and select first leaf of the first node.

watertrac_dev
9 Oct 2014, 6:20 AM
I've updated the fiddle. Take a look.

shakerkk
9 Oct 2014, 6:23 AM
Very nice i like it the problem is that mine is not working i get Cannot select node , my
var firstChildNode = treepanel.getRootNode().firstChild; is null :(

watertrac_dev
9 Oct 2014, 6:27 AM
What browser are you using? The fiddle is working fine for me on the latest Chrome stable release.

shakerkk
9 Oct 2014, 6:29 AM
I'm using Chrome this is my code


initComponent: function () {
var me = this;
me.storeReference = Ext.create('aw.store.tree.ProjectStructures');
Ext.apply(me, {
store: me.setStore(),
listeners: {
itemclick: me.pageOpen,
boxready: function(treepanel) {
debugger;
var firstChildNode = treepanel.getRootNode().firstChild;
try {
firstChildNode.expand(false, function() {
treepanel.selectPath(firstChildNode.firstChild.getPath());
}, treepanel);


} catch (e) {
Ext.Msg.show({
title: 'Exception caught',
msg: 'Cannot select node',
buttons: Ext.Msg.OK,
icon: Ext.Msg.WARNING
});
}
}
},

watertrac_dev
9 Oct 2014, 6:32 AM
Is your store automatically loaded? What does the data loaded into the store look like?

shakerkk
9 Oct 2014, 6:36 AM
Its complicated :)) i managed to grab something like ..treepanel.store.tree.root

watertrac_dev
9 Oct 2014, 6:39 AM
Does the example provide enough guidance to answer your question?

shakerkk
9 Oct 2014, 6:42 AM
Yes thanks a lot .