Results 1 to 6 of 6

Thread: CardLayout and setActiveItem

  1. #1

    Question CardLayout and setActiveItem


    I have a Panel and a GridPanel that I need to switch between. A CardLayout seems like the perfect tool to do so, but I can't get it to work.

    Here's the code I have:
        centerpanel = new Ext.Panel({
            layout: 'card',
            activeItem: 0,
            items: [homepanel, browser.grid]
    Unfortuneatly, getLayout() returns a string and not a ContainerLayout object (in the API docs it says it returns the ContainerLayout object, but that's not true).

    Does anybody know how to get the layout object so that I can call public functions on it?


  2. #2
    Sencha User
    Join Date
    Mar 2007


    getLayout() returns an object as the doc says. Has the panel been rendered when you call that line? Are you using 2.0 Final?

  3. #3
    Sencha User Animal's Avatar
    Join Date
    Mar 2007


    Until the Panel is rendered, there will not be a layout object, it will still be the string type you specified.

    If you want item 1 to be the initial active item, use activeItem:1 instead of activeItem:0

  4. #4


    Right, that wasn't realistic code, but I wanted to demonstrate the problem I was having.

    Once I waited for the panel to be rendered, it worked fine except that for some reason I can see both cards. I'll work on that for a bit and post a new thread if I can't figure it out.

    Thanks a lot!

  5. #5


    Thanks for the help. I was staring at this for a few hours today before resorting to Google.

    I experienced this issue with an ancestor of a TabPanel child whose layout property was simple the string 'card'. Added a property of 'deferredRender: false' to my TabPanel's config object, and everything's rendering.

  6. #6


    I'm using ExtJS 4.
    This code works for me... I can switch between panel using getLayout()...
    Moreover, getLayout() is returning an object in my code...
    I dont know whats wrong with this one

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts