Results 1 to 7 of 7

Thread: How to add CenterLayoutExample to Viewport

  1. #1
    Ext User
    Join Date
    Jan 2009
    Posts
    8
    Vote Rating
    0
      0  

    Question How to add CenterLayoutExample to Viewport

    Let's say I've the following in my onModuleLoad():

    Viewport vp = new Viewport();
    CenterLayoutExample cle = new CenterLayoutExample();
    ???
    vp.add(cle);
    ???
    RootPanel.get("slot1").add(vp);

    CenterLayoutExample is from http://extjs.com/examples/layouts/centerlayout.html

    So what I need to do in place of question marks to get the example rendered in the center and middle of my browser window?
    I've got it to work with gxt 1.2 but in gxt 1.2.1 I see nothing because there is always some div in it with height 0.
    I've tried to set the height manually but it seems that I'm missing something because the special div doesn't change. Only the parent and the child divs.
    Please point me in the right direction!
    Thanks.
    Markus

  2. #2
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    You cant use a viewport in your example, as you arent adding it to the body but to some other element with id "slot1".


    Code:
    CenterLayoutExample cle=new CenterLayoutExample();
    cle.setSize(400, 600);
    RootPanel.get("slot1").add(cle);

  3. #3
    Ext User
    Join Date
    Jan 2009
    Posts
    8
    Vote Rating
    0
      0  

    Default

    Hi Sven,
    thanks for your patience. But it doesn't help me.
    I can use RootPanel.get().add(vp) , too.
    But I don't see anything.

    I attach a new image where you can see the divs.

  4. #4
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    Code:
    vp.setLayout(new FitLayout());

  5. #5
    Ext User
    Join Date
    Jan 2009
    Posts
    8
    Vote Rating
    0
      0  

    Default

    Ah, cool. That's it.
    But I don't understand why vp.setLayout(new FlowLayout()); doesn't show anything at all.
    The childs have size, so why do you need a FitLayout?
    Is it because the "cle" is rendered/sized before the "vp" and vp has first height 0?

  6. #6
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    If you use FlowLayout you have to size the CenterLayoutExample:

    Code:
    cle.setSize(400, 600);

  7. #7
    Ext User
    Join Date
    Jan 2009
    Posts
    8
    Vote Rating
    0
      0  

    Default

    Ok. I think I've got it. I've tried some setSize at different places and now I understand what's going on.
    Thanks for your help. Are you paid by Ext?

Posting Permissions

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