PDA

View Full Version : Best way to load Accordion item the first time it expands (render,expand events)



art.dev.ext
5 Nov 2012, 9:29 AM
Hi all !

Consider having an Accordion panel with 2 items (both TreePanels with 2 different stores).

{
xtype: 'panel',
layout: 'accordion',
items:[
{xtype:'treepanel',id:'tree1',store:'TreeStore1'},
{xtype:'treepanel',id:'tree2',store:'TreeStore2',collapsed:false}
]
}

When application launches, the TreeStore2 must be loaded at render time (beforerender ?). When user activates the 1st treepanel, TreeStore1 must be loaded.

Which event listener do I have to set on both treepanels (or only on accordion) in order to load stores only if needed ?

I tried beforeexpand on both, but accordion does not fire this event for the tree2 panel at render time (it is expanded by default)

I tried beforerender on both, but accordion fires this event for both panel so the two stores get loaded, the thing I do not want.

I also do not want to have different listeners depending on 'collapsed' is false (or not at render time).

Any help would be really appreciated.

mitchellsimoens
7 Nov 2012, 8:25 AM
You can listen to the expand event on the item

art.dev.ext
9 Nov 2012, 8:01 AM
Thank for your response, but in my case, no 'expand' event is raised at render time, when accordion renders and set an item expanded by default.

ettavolt
12 Nov 2012, 2:46 AM
Try boxready event - that will definitely fire only once and after component is rendered and shown.

art.dev.ext
15 Nov 2012, 5:40 AM
It sounds great !
I will test this !
thank you