1. #1
    Sencha User
    Join Date
    Sep 2009
    Posts
    28
    Vote Rating
    0
    Dustin Graham is on a distinguished road

      0  

    Default Portal: Remove and Add Portlets?

    Portal: Remove and Add Portlets?


    Okay, I am missing something basic...

    I have a portlet: p = new Ext.ux.Portlet({ ... });
    And a portal: portal = new Ext.ux.Portal({ ... });
    To start, the portal has items -> columns -> my portlets.

    I have a toggle button that:
    p.ownerCt.remove(p);
    portal.doLayout();

    Then, to re-add, I call:
    Ext.getCmp('myPortalColumn').add(p);
    portal.doLayout();

    Everything seems to work, except the portlet does not allow for drag and drop after being re-added.

    Other portlets can be dragged around the removed/re-added portlet. And, of course the portlet still has the move cursor (CSS... ), but won't let me start drag.

    I am having problems trying to configure this. The portal example shows how to remove portlets, but it doesn't show (as far as I can tell) how to re-add the removed portlets.

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    Removing a panel will destroy it! A destroyed panel can't be reused.

    You should use:
    Code:
    p.ownerCt.remove(p, false);
    portal.getComponent(colIndex).add(p);
    portal.doLayout();

  3. #3
    Sencha User
    Join Date
    Sep 2009
    Posts
    28
    Vote Rating
    0
    Dustin Graham is on a distinguished road

      0  

    Default


    Hm. Yea. I did try doing false, since I thought it was being destroyed. But, looking at the code, I thought perhaps it wasn't destroying it since I didn't see a place where autoDestroy was set to true.

    But, when stepping through the javascript, it did in fact destroy the panel. However, I was deceived because re-adding the destroyed panel seemed to work somewhat? But, of course, bad practice.

    I did try your suggestion of passing in false. But, when I pass in false, and call portal.doLayout(); the portlet actually does not disappear...

    Strange huh?

    So. My solution is portlet.hide(); portlet.show(); portal.doLayout(); Added bonus of keeping the portlet in the original column without needing to remember which column it was in.

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    Removing a component from a container without destroying it will not remove the component from the DOM. Ext assumes that you will either move the component DOM to a different location or hide the component.

    ps. Hiding the component can sometimes cause problems with the container layout, because the DOM is still inside the container DOM.

  5. #5
    Sencha User
    Join Date
    Sep 2009
    Posts
    28
    Vote Rating
    0
    Dustin Graham is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    Removing a component from a container without destroying it will not remove the component from the DOM. Ext assumes that you will either move the component DOM to a different location or hide the component.

    ps. Hiding the component can sometimes cause problems with the container layout, because the DOM is still inside the container DOM.
    Interesting. Well that explains why it didn't disappear. So then I guess that means we need to do something like

    PHP Code:
    p.ownerCt.remove(pfalse);
    p.hide();
    portal.doLayout(); 
    Then...
    PHP Code:
    portal.getComponent(colIndex).add(p);
    p.show();
    portal.doLayout(); 
    Hmm... I don't know. I am currently happy just hiding and showing it. I understand there may be issues since it's still in the DOM even though I hid it. If I run into issues I will remember this. I have other issues I want to tackle for now.

    THANKS for the help so far Condor! I really appreciate it.

  6. #6
    Ext User
    Join Date
    Aug 2008
    Location
    Cluj-Napoca, Romania
    Posts
    15
    Vote Rating
    0
    symx is on a distinguished road

      0  

    Default


    I have a similar problem but with a form. I have a combo box in a fieldset in a formpanel.
    I try to add different fields to the fieldset based on the value selected in the combo box.

    Adding works, but when I tried to delete it only deletes if I chose to destroy the component. I tried hiding and showing and that works without destroying but the problem with hiding the component is that it still remains in the DOM and it's contents will be submitted when sending the form. If I don't want that my only solution is to destroy and create the fields each time.

    A bigger problem I have now is that even if the field I add is correctly removed and destroyed, it's label still remains in the fieldset. Are labels saved someplace else?

    I'm using Ext 2.2.1.

  7. #7
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    1. Don't create and destroy components. Create them all and hide the components you don't want to show.
    2. You not only need to hide fields, but you also need to disable them so they won't cause validation errors and won't be submitted.
    3. Hiding fields in a form layout won't properly hide the field labels. For Ext versions below 3.0.1 you need the patch from this thread.

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar