PDA

View Full Version : Accordion layout - fire the event expand on add



23 Oct 2014, 1:00 AM
Hello,

I have some panels that i insert in a layer having accordion layout.
What i would like is to execute some code on the panel that is expand.

This is what i do


for(i=0; i<elements.length; i++){
/*get the json data*/
var message = elements[i].data;
console.log(message);

var form = Ext.create('MyApp.view.GroupDescription');
form.title = "Group " + message.id + ": " + message.description;
/*we load the values*/
form.loadMsg(message);
container.add(form);
}

So, i may easily handle the expand/beforeexpand event. That's ok, it works, but not always.

Suppose i add three panel: A,B,C. (A,B,C are panels of the same class as above)
What i see is that A is expanded, B and C are collapsed.

So, since this is the output, i would have been expected to handle the "expand" event on A. I tried, but A doesn't fire such event.

But if i click on B, the event is fired and when i go back on A, the event "expand" is correctly fired and handled.
Hence, how could i handle the event that A is expanded after adding? :-?

thanks in advance.

-----edit----
ps: i use the "loadMsg" just to keep track somewhere in the field which ID is. Then i use such ID to download information from the server when the panel is expanded.

slemmon
23 Oct 2014, 6:35 PM
I would do something like the following where I do a single check for the expanded panel on afterrender:

c8u

23 Oct 2014, 10:40 PM
Oh!
Great idea. I didn't think about it.
Actually this is all what i need, indeed.

Thank you so much for the suggestion.