Results 1 to 6 of 6

Thread: CardLayout and setActiveItem

  1. #1

    Question CardLayout and setActiveItem

    Hello,

    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:
    Code:
        centerpanel = new Ext.Panel({
            layout: 'card',
            activeItem: 0,
            items: [homepanel, browser.grid]
        });
    
        centerpanel.getLayout().setActiveItem(1);
    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?

    Thanks,
    Justin

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    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
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    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

    Default

    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

    Default

    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

    Default

    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
  •