Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Add already rendered Component to other one.

  1. #1
    Sencha User
    Join Date
    Feb 2009
    Location
    Germany, Nuremberg
    Posts
    39

    Lightbulb Add already rendered Component to other one.

    Hi, guys, need your help today)

    I have Panel with border layout with two elements: north and center.
    North - it's a treePanel.
    Center - formPanel or gridPanel, dependes of which node you are selected in the tree.

    So, what's the problem. I've created two instance - one for form and one for grid, then i'm trying to add these components to common panel via add() method, then doLayout(), everything is okey. Couz center depends on node-type i need replace grid to form or from to grid. So, i remove it each time with false parameter, then i try add grid/form back to panel via add()... it's working... but doLayout() doesnt work and i cant see my grid/form again.

    So, it works only if it wasnt rendered before. How can i add already rendered component to already rendered Panel properly?

    some code example:
    Code:
                if(panel.items.getCount() == 0 || panel.items.first().xtype != 'xapp_calculatorGrid'){
                  panel.removeAll(false);
                  panel.add(grid)//.ownerCt.doLayout();
                  panel.doLayout(false, true);
    
                  console.log('render grid');
                }
    
    
                if(panel.items.getCount() == 0 || panel.items.first().xtype != 'xapp_calculatorForm'){
                  panel.removeAll(false);
                  panel.add(form)//.ownerCt.doLayout();
                  panel.doLayout(false, true);
    
                  console.log('render form');
                }

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Don't make your life so difficult! This is a classic case for layout:'card'!

  3. #3
    Sencha User
    Join Date
    Feb 2009
    Location
    Germany, Nuremberg
    Posts
    39

    Default

    Can i do things like this?

    Code:
    SExt.MyPanel = Ext.extend(Ext.Panel, {
        layout  : 'border',
        border  : false,
        defaults: {
             border: false,
             split : true,
             layout: 'fit'
        },
        items: [{
                  region    : 'east',
                  height    : 200
                },
                {
                  region    : 'center',
                  layout    : 'card',
                  activeItem: 0
                }]
    ...
    });
    should i create additional instance of Ext.Panel in center region? or it's going by default in this case?

    Which value should be set in activeItem if there is no items by default?

  4. #4
    Sencha User
    Join Date
    Feb 2009
    Location
    Germany, Nuremberg
    Posts
    39

    Default

    dont worry about constructor calling and initComp method, i cut it from here..

  5. #5
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    So you actually need 3 cards:
    - An empty one
    - A grid
    - A form

  6. #6
    Sencha User
    Join Date
    Feb 2009
    Location
    Germany, Nuremberg
    Posts
    39

    Default

    yeah, already did it ;-) thank you for quick feedback.

  7. #7
    Sencha User
    Join Date
    Feb 2009
    Location
    Germany, Nuremberg
    Posts
    39

    Default

    Heh, now there is a problem with loadMask... at first load it shows load mask at top left corner of the grid. I guess the same problem like here - http://www.sencha.com/forum/showthre...-in-empty-Grid

    Any suggestion?)

  8. #8
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    That is usually caused by a misconfigured layout.

    What is your current layout?

  9. #9
    Sencha User
    Join Date
    Feb 2009
    Location
    Germany, Nuremberg
    Posts
    39

    Default

    card layout.

  10. #10
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Funny... I mean the entire config object (how the grid is included in its containers).

Page 1 of 2 12 LastLast

Similar Threads

  1. Changing atribute on already rendered component
    By allistar in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 14 Oct 2009, 12:52 PM
  2. How to determine that a component is rendered?
    By sksoft in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 13 Feb 2009, 4:07 AM
  3. Replies: 2
    Last Post: 10 Sep 2008, 11:50 PM
  4. getting a component's default size before it has been rendered
    By asimpkins in forum Ext GWT: Help & Discussion (1.x)
    Replies: 1
    Last Post: 23 Aug 2008, 7:14 AM
  5. can not add component after rendered?
    By [email protected] in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 17 Dec 2007, 11:45 PM

Posting Permissions

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