PDA

View Full Version : CardLayout: _index_ of the active item ?



drunkmoose
15 Mar 2011, 7:53 AM
Hi there,

I'm building this dynamic wizard in which the order of the cards might not be in the same order depending on user inputs.

The object returned by CardLayout.activeItem() only has an id property, not an index (ie: is the activeItem the 5th, 3rd or first card in the lot?)

Having an index property would really simplify my tasks. (ie: regardless of the id, when I press next, I want to go to next page)

Do you have any advices ? Perhaps my method needs tweaking...

Thanks! :)

EDIT: I just tried:



var lay = Ext.getCmp('wizardForm').getLayout();
var l = Ext.getCmp('wizardForm').items.indexOf(lay.activeItem.id);
console.log(l);


But that returns -1 all the time (?)

fay
15 Mar 2011, 8:19 AM
use indexOfKey



var lay = Ext.getCmp('wizardForm').getLayout();
var l = Ext.getCmp('wizardForm').items.indexOfKey(lay.activeItem.id);

steffenk
15 Mar 2011, 8:21 AM
var l = Ext.getCmp('wizardForm').getActiveTab();

drunkmoose
15 Mar 2011, 9:32 AM
Neither does BasicForm or FormPanel have a getActiveTab() method.

fay's solution works great though.

Thanks :)