PDA

View Full Version : activeItem and cardLayout



sudo rm -rf /
9 May 2012, 5:21 AM
Hi. I am trying to set an activeItem for a cardlayout. I know that after everything is laid out one would use myCardContainer.getLayout().setActiveItem(); I also know that before it has a layout one would set the activeItem property. In 4.1 I found a middle ground that neither work.


Ext.onReady( function() {
Ext.create( 'Ext.container.Viewport', {
layout: 'border',
items: [
{
region: 'west',
width: 300,
listeners: {
afterrender: function() {
var content = this.nextSibling();
console.log( content.rendered);
content.activeItem = 'green';
}
}
},
{
region: 'center',
layout: 'card',
items: [
{
bodyStyle: "background: red",
itemId: 'red'
},
{
bodyStyle: "background: green",
itemId: 'green'
}
]
}
]
} );
} );



In 4.07 it would set correctly to the green item. In 4.1 it will not work even though the console is logging that it is not even rendered. At this point I can't use setActiveItem either. If I was to do it in the beforerender event, it would work in 4.1. Is there another way to accomplish this?

The code is a simplified version of what I am hitting. I could probably figure out the logic in a beforerender event, but I will still need the afterrender for other reasons and I hate to repeat code.