Hybrid View

  1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    174
    Answers
    10
    Vote Rating
    1
    netemp is on a distinguished road

      0  

    Default Unanswered: ExtJs 4.1 : Is calling doLayout() method a must after adding child to a parent?

    Unanswered: ExtJs 4.1 : Is calling doLayout() method a must after adding child to a parent?


    In our application, we have a tabpanel in which we are adding/removing the panels dynamically.


    The panels get added at the click of a menu item by the following code in menu handler:

    Code:
        Ext.getCmp('mainTabPanel').add(getPanel());
    Here getPanel() method returns the panel after creating it.

    In this context, could someone guide at the following:

    a. Is it necesarry to call doLayout() on mainTabPanel after the add method?

    b. Will a call to doLayout() not slow the rendering?

    c. Will a call to doLayout() take care of all the issues related to rendering, like scrollbars esp.?

    d. The method getPanel() should return an already created panel (using Ext.create) or should it return a config object (having xtype:'panel')? Which one should be preferred for better performance keeping time in mind?

    Thanks for any help in advance.

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,927
    Answers
    656
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    You will need to call doLayout to ensure your layout is properly calculated.

    I would think referencing a panel id (itemId) directly would provide faster access than cycling through xtypes, but I am not sure how your getPanel is setup.

    Scott.

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Posts
    174
    Answers
    10
    Vote Rating
    1
    netemp is on a distinguished road

      0  

    Default


    Thanks for the reply Scott.

    Assuming that the id of main tab panel is 'mainTabId' and that of the child panel is 'panelId', thus, could you please guide at following:

    1. .Should I call doLayout() on panel or main tab panel? That is, Ext.getCmp('mainTabId').doLayout() or Ext.getCmp('panelId').doLayout()?

    2. Also, in getPanel(), should I create panel using Ext.create and then return it, or its preferable to return a panel object specifying xtype?

    Thanks again.

  4. #4
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Answers
    124
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    HI!

    You have to call dolayout() method of container in which you are adding elements.
    like , if you are adding a textfield in a panel, you have to call dolayout () method of panel, not the textfield.

    dolayout() will detect the changes in contents of container and then do lay outing based on the same.

    Also, it depends on your choice whether to use
    Ext.create or Xtype,
    Both will work finer, but my opinion is to return an xtype instead of Ext.create.
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  5. #5
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,828
    Answers
    453
    Vote Rating
    609
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    No, you don't need to call doLayout. You can easily verify it:

    Code:
    var p = new Ext.panel.Panel({
        renderTo: document.body,
        width 200,
        height: 200,
        layout: 'fit'
    });
    
    p.add({
        title: 'Foo'
    });
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  6. #6
    Sencha User
    Join Date
    Feb 2011
    Posts
    174
    Answers
    10
    Vote Rating
    1
    netemp is on a distinguished road

      0  

    Default


    Thanks for the posts Sword-It and Evant.

    @Sword-Id: You have really made things very clear. Thanks.

    @Evant: I was actually under the same impression that we don't need to call doLayout() after adding the child. But when it gets a bit complicated, for example, a panel having a form at north, grid at bottom, and form at south and say it uses ux.center layouts for form and selection model at the grid. If such a panel is added to some tabpanel dynamically then the center layout stops working and forms fall towards left if the call to doLayout() is not made.

    We faced such a situation and only after this we realized that its mandatory and safer to call doLayout() of the parent panel after a child has been added to it.

    The issue with a call to doLayout() is that it increases the rendering time.

    So any thoughts on this that how can this time consumed due to doLayout() be reduced? As in, any other alternative over doLayout()?

    Thanks for the time so far.

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi