1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    33
    Answers
    4
    Vote Rating
    4
    Alexander Bauer is on a distinguished road

      0  

    Default Answered: Reuse same instance

    Answered: Reuse same instance


    Hi,

    I have a custom layout. The base panel has a border layout. It consists of a west panel (menu) a north tabbar (height : 25, the tabbar is the only visible one) and a center panel, which always replaces its contents using .removeAll(); and .add(cmp);

    I need this layout because I want to be the tabbar above the west & center regions, not only the center region but the tab content should be in the center panel. Now when you click on a tab, it uses the activate event and puts its items property into the center panel.

    While this works fine so far, I have issues reusing same components. A tab consists of a form and when you edit the form, switch to another tab or a menu button I have to remove it from the center panel (removeAll()) and when you select the tab again I need to add the center panel.

    Code:
    var tab = Ext.create('Ext.panel.Panel', {
                closable : true,
                title : ''
                record : record,
                listeners : {
                    activate : function() {
                        this.myRequest = Ext.create('myPanel', {
                                    record : record,
                                    myTab : this
                                });
                        centerPanel.setItem(this.myRequest);
                    }
                }
            });
    When I save the panel for reusing like :
    Code:
     if(!this.myRequest) {
        this.myRequest = Ext.create('myPanel', {
                                    record : record,
                                    myTab : this
                                });
    }
    centerPanel.setItem(this.myRequest);
    I cant get it render again. If I use Ext.create() or xtype, the changes of form fields will be lost, since its a new instance.

    So the question is: is there a way to reuse the same instance multiple times after .add() and .remove() ?

    I attached a screenshot how my layout should look like.
    extjs-reuse-cmp.jpg

  2. ok, nevermind... how stupid.
    just had to add : removeAll(false); to prevent the components from being destroyed.

  3. #2
    Sencha User
    Join Date
    Jul 2012
    Posts
    33
    Answers
    4
    Vote Rating
    4
    Alexander Bauer is on a distinguished road

      0  

    Default


    ok, nevermind... how stupid.
    just had to add : removeAll(false); to prevent the components from being destroyed.

  4. #3
    Ext JS Premium Member SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    385
    Answers
    3
    Vote Rating
    8
    SebTardif is on a distinguished road

      0  

    Default


    You should mark your question answered.

  5. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    44
    Answers
    4
    Vote Rating
    0
    nothing is an unknown quantity at this point

      0  

    Default


    Thanks man. removeAll(false); was the solution I was looking for 2 days now...........................

Thread Participants: 2

Tags for this Thread

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