PDA

View Full Version : card layout, how to change cards?



smick
2 Nov 2010, 4:24 PM
Hello,

Well, I know about setActiveItem, but how do I get a handle on my card layout?

my viewport looks like this:


var application = new Ext.Viewport({

layout: 'border',
items: [{
region: "north",
margins: '0 100 0 100',
contentEl: 'header'
},{
id: 'centerPanel',
region: "center",
margins: '0 100 0 100',
layout: "card",
activeItem: 0,
items: [ search_page, view_page ]
}]
});


and my clickable thingy looks like this:




Ext.select('.application-search').on('click', function() {

var centerPanel = application.getComponent('centerPanel');
centerPanel.setActiveItem(2);

})

But it no worky.

I suppose I'm just using the wrong method of getting a handle on my card stack. What would be the correct method of doing this?

Thanks again and again. :s

httpdotcom
2 Nov 2010, 6:08 PM
Ext.select('.application-search').on( 'click', function() {
Ext.getCmp("centerPanel").setActiveItem(1); // or 0 to return to search page
} )

Didn't work because items in the "card" array are 0...count()-1
0 = search_page
1 = view_page
...

Condor
3 Nov 2010, 12:47 AM
setActiveItem is a method of CardLayout, not of Container!

Ext.select('.application-search').on('click', function() {
var centerPanel = application.getComponent('centerPanel');
centerPanel.layout.setActiveItem(2);
});