Add component after Removeall()

  1. #1

    Add component after Removeall()

    Hello,

    I would like to delete the content of a panel and then populate it again with new data but im not able to do it. After Removeall() nothing happens.

    here is a sample code:

    On pageload I am creating a checkbox and a panel, when I change the Checkbox value it should delete panel 1 on panelarticulos AND load panel 2 on it. But Only deletes panel 1 and it does not create panel 2.

    I know I am creating panel 2, because if I delete the RemoveAll() function, both panels are appearing.

    Is there a way to do this?

    .aspx
    <body>
        <form id="formGeneral" runat="server">
        <ext:ResourceManager ID="ResourceManagerExt" runat="server" IDMode="Explicit" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="columnlayout" >
            
            <Items>
                <ext:Panel ID="panelizq" runat="Server" ColumnWidth="0.25" Frame="false" Layout="ColumnLayout">
                    <Items>
                        
                    </Items>
                </ext:Panel>
                <ext:Panel ID="panelarticulos" runat="Server" ColumnWidth="0.75" Frame="true" layout="columnlayout" height="500" autoscroll="true">
                    <Items>
                        
                    </Items>
                </ext:Panel>
            </Items>
        </ext:Viewport>
        </form>
    </body>
    .aspx.cs
    protected void Page_Load(object sender, EventArgs e)
            {
    
                Ext.Net.Checkbox checkfamilia = new Ext.Net.Checkbox();
                checkfamilia.ID = "check";
                checkfamilia.Name = "check";
                checkfamilia.BoxLabel = "reload panel";
                checkfamilia.MarginSpec = "0 0 0 60";
                checkfamilia.Cls = "normalbox";
                panelizq.Add(checkfamilia);
    
                checkfamilia.DirectEvents.Change.Event += new ComponentDirectEvent.DirectEventHandler(this.Filtrar);
    
                Ext.Net.Panel panelitembehind = new Ext.Net.Panel();
                panelitembehind.ID = "panel1";
                panelitembehind.ColumnWidth = 0.333;
                panelitembehind.Frame = true;
                panelitembehind.Height = 60;
                panelitembehind.Layout = "columnlayout";
                panelarticulos.Add(panelitembehind);
    
                   
            }
    
            public void Filtrar(object sender, DirectEventArgs e)
            {
               panelarticulos.RemoveAll(true);
    
                Ext.Net.Panel panelitembehind = new Ext.Net.Panel();
                panelitembehind.ID = "panel2";
                panelitembehind.ColumnWidth = 0.5;
                panelitembehind.Frame = true;
                panelitembehind.Height = 200;
                panelitembehind.Layout = "columnlayout";
                panelarticulos.Add(panelitembehind);
    
                panelarticulos.Render();
    
            }
    Thank you very much.
  2. #2
    Hello @pascu!

    I don't see how you could make the panel appear with just commenting out the line 27 of your .aspx.cs code. At least here it does not work. In fact, it shouldn't work. I believe the RemoveAll() call is not related to the problem at all. But you're treating an already instantiated panel the same way you do while creating it.

    The difference is, when you are creating the panel you are determining the contents it will draw within when the page is loaded. Once built, you can't just point the components it should contain, but rather make the new component be drawn by itself so it can be effectively rendered on screen.

    In other words, in your .aspx.cs you should remove the line 37 and invert the roles in line 35 to:

    panelitembehind.AddTo(panelarticulos)
    Then it should work as you intended.

    Last, but not least, please provide full test cases following our Forum Guidelines For Posting New Topics or we may be unable to assist you.

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Edit: its working fine
    Last edited by Pascu; Oct 02, 2017 at 9:06 AM.

Similar Threads

  1. Please help about combo removeall function
    By rickywu in forum 4.x Help
    Replies: 1
    Last Post: Jul 21, 2016, 12:50 AM
  2. [CLOSED] ComboBox RemoveAll
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 12, 2012, 11:29 AM
  3. [CLOSED] GridPanel removeAll
    By softmachine2011 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 03, 2012, 2:53 PM
  4. [CLOSED] removeAll EditableGrid
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 07, 2011, 10:07 AM
  5. RemoveAll selection of MultiSelect
    By n_s_adhikari@rediffmail.com in forum 1.x Help
    Replies: 2
    Last Post: Aug 09, 2009, 5:34 PM

Posting Permissions