[CLOSED] Load control to 1 tab at time

Page 1 of 3 123 LastLast
  1. #1

    [CLOSED] Load control to 1 tab at time

    Hi,
    I've certain requirement. Need to make loaded 1 tab at time rest of them (in this moment last active should be clear from any items existing inside of this oldTab). Could you please tell me how should I do that in v2.2 ?

    it's related question to this one: thread
    Last edited by Daniil; Jun 04, 2013 at 5:08 AM. Reason: [CLOSED]
  2. #2
    Hello!

    Sorry, but I don't quite understand your requirements. Can you provide sample of your problem. You can use the following sample:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET Examples</title>
    
        <script runat="server">
            protected void AddTab(object sender, DirectEventArgs e)
            {
                Ext.Net.Panel panel = new Ext.Net.Panel
                {
                    Title = "New Tab",
                    Closable = true,
                    Layout = "Fit",
                    Items = { 
                        new Container
                            {
                                Html = "My container"
                            }
                    }
                };
                TabPanel1.Add(panel);
                panel.Render();
                
                TabPanel1.SetLastTabAsActive();            
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Window 
                runat="server" 
                Width="680" 
                Resizable="false"
                Closable="false"
                Height="500" 
                Layout="FitLayout">
                <Items>                
                    <ext:TabPanel ID="TabPanel1" runat="server">
                        <TabBar>
                            <ext:Button runat="server" Flat="true" Icon="Add">
                                <DirectEvents>
                                    <Click OnEvent="AddTab" />
                                </DirectEvents>
                            </ext:Button>
                        </TabBar>
                    </ext:TabPanel>
                </Items>
            </ext:Window>
        </form>
    </body>
    </html>
  3. #3
    [QUOTE=Baidaly;109640]Hello!

    Sorry, but I don't quite understand your requirements. Can you provide sample of your problem. You can use the following sample:

    <%@ Page Language="C#" AutoEventWireup="true" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        public class ControlSample : Ext.Net.Container
        {
            private Ext.Net.Container containerTop;
            private Ext.Net.Container containerMain;
            private Ext.Net.Button btnCreateSomething;
    
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                this.LayoutConfig.Add(new VBoxLayoutConfig { Align = VBoxAlign.Stretch });
                btnCreateSomething = new Ext.Net.Button { ID =this.ID+ "btnCreate", Text = "Create", Icon = Icon.Add };
                containerTop = new Container { ID = this.ID + "containerTop", Height = 26 };
                containerTop.Items.Add(btnCreateSomething);
                this.Items.Add(containerTop);
                containerMain = new Container { ID = this.ID + "containerMain", Flex = 1, Html = "Some text for example purpose", Layout=LayoutType.Fit.ToString()};
                this.Items.Add(containerMain);
            }
        }
        public string ActiveTabIdForRecreating
        {
            get { return Session["ActiveTabForRecriating"] == null ? "" : (string)Session["ActiveTabForRecriating"]; }
            set { Session["ActiveTabForRecriating"] = value; }
        }
    
        
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            int count = 5;//number of generated tabs
            int index = 0;
            Ext.Net.Panel panel;
            ControlSample control;
            while(count!=index)
            {
                panel = new Ext.Net.Panel { ID = "tab" + index, Title = "Tab" + index, Closable = false, Collapsible = false, Layout = LayoutType.Fit.ToString() };
                if (string.IsNullOrEmpty(ActiveTabIdForRecreating) || ActiveTabIdForRecreating.Contains(panel.ID))
                {
                    control = new ControlSample { ID = "someId"+index };
                    panel.Items.Add(control);
                    ActiveTabIdForRecreating = panel.ID;
                }
                tabPanel.Items.Add(panel);
                index++;
            }
        }
        
        [DirectMethod(Timeout=300000)]
        public void AddTab(string newTab,string oldTab)
        {
            Ext.Net.Panel activatedTab = tabPanel.Items.FirstOrDefault(x => x.ClientID == "App."+newTab) as Ext.Net.Panel;
            Ext.Net.Panel lastActiveTab = tabPanel.Items.FirstOrDefault(x => x.ClientID == "App." + oldTab) as Ext.Net.Panel;
            if (lastActiveTab != null)
            {
                lastActiveTab.Items[0].Dispose();//here is the part I don't know how to do in v2.2 removing from client side this first item of lastActiveTab
                Ext.Net.X.AddScript(lastActiveTab.Items[0].ClientID+".destroy()");
            }
            if (activatedTab != null)
            {
                ControlSample control = new ControlSample { ID = "someId" };
                activatedTab.Items.Add(control);
                control.Render();
                ActiveTabIdForRecreating = activatedTab.ID;
            }
            Ext.Net.X.Mask.Hide();
        }
        
    </script>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager runat="server" IDMode="Legacy"></ext:ResourceManager>
        <ext:Viewport runat="server">
            <LayoutConfig>
                <ext:VBoxLayoutConfig runat="server" Align="Stretch" />
            </LayoutConfig>
            <Items>
                <ext:Container ID="topContainer" runat="server" Height="40">
                    <Items>
                        <ext:Button ID="btn" Text="Top" runat="server"></ext:Button>
                    </Items>
                </ext:Container>
                <ext:Container ID="mainContainer" runat="server" Flex="1">
                    <LayoutConfig>
                        <ext:FitLayoutConfig runat="server" />
                    </LayoutConfig>
                    <Items>
                        <ext:TabPanel ID="tabPanel" runat="server">
                            <Listeners>
                                <TabChange Handler="if(newTab.items.getCount()>0) { return false; } else { Ext.net.Mask.show({ msg : 'Loading control in progress...', el : newTab }); #{DirectMethods}.AddTab(newTab.id, oldTab.id); }"></TabChange>
                            </Listeners>
                        </ext:TabPanel>
                    </Items>
                </ext:Container>
            </Items>
        </ext:Viewport>
    </body>
    </html>
    Last edited by ViDom; May 22, 2013 at 3:12 PM.
  4. #4
    Thank you for the sample. Please clarify what are the steps to reproduce the problem.
  5. #5
    Quote Originally Posted by Daniil View Post
    Thank you for the sample. Please clarify what are the steps to reproduce the problem.
    I've edit my sample.

    Try it like this:
    start this sample click on Tab1 (control doesn't load as well as Tab0.items collection doesn't be clear)
    then click on Tab0 again and again on Tab1.
  6. #6
    Hello!

    Sorry, but can you say step by step what should happen? You dispose controls and then recreate them but it's not clear why do this.

    If you want to display this Container control only on one tab it's better to use JavaScript. However, please, clarify.
  7. #7
    Quote Originally Posted by Baidaly View Post
    Hello!

    Sorry, but can you say step by step what should happen? You dispose controls and then recreate them but it's not clear why do this.

    If you want to display this Container control only on one tab it's better to use JavaScript. However, please, clarify.
    In first load of current page (from sample) should be first Tab in this sample Tab0 fully loaded (contain control in items collection)
    If user change active tab for another one:
    1. get rid of all items from Tab0.items (destroy them or how you want to say of it)
    2. load control to currectly activated Tab1.items collection
    3.reapet it with every Tab change

    Is it clear now?
  8. #8
    Thank you, we get closer to understand.

    What about the following scenario? A tab Panel can be organized as a custom control.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        [DirectMethod]
        public static string GetTabContent(string parameters)
        {
            Dictionary<string, string> prms = JSON.Deserialize<Dictionary<string, string>>(parameters);
    
            Ext.Net.Label label = new Ext.Net.Label(prms["tabId"] + " " + DateTime.Now.Second);
            return ComponentLoader.ToConfig(label);
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />      
            
            <ext:TabPanel runat="server">
                <Items>
                    <ext:Panel ID="Panel1" runat="server" Title="Tab 1">
                        <Loader 
                            runat="server" 
                            Mode="Component" 
                            DirectMethod="App.direct.GetTabContent"
                            ReloadOnEvent="true"
                            TriggerEvent="activate"
                            RemoveAll="true">
                            <Params>
                                <ext:Parameter Name="tabId" Value="this.id" Mode="Raw" />
                            </Params>
                        </Loader>
                    </ext:Panel>
                    <ext:Panel ID="Panel2" runat="server" Title="Tab 2">
                        <Loader 
                            runat="server" 
                            Mode="Component" 
                            DirectMethod="App.direct.GetTabContent"
                            ReloadOnEvent="true"
                            TriggerEvent="activate"
                            RemoveAll="true">
                            <Params>
                                <ext:Parameter Name="tabId" Value="this.id" Mode="Raw" />
                            </Params>
                        </Loader>
                    </ext:Panel>
                    <ext:Panel ID="Panel3" runat="server" Title="Tab 3">
                        <Loader 
                            runat="server" 
                            Mode="Component" 
                            DirectMethod="App.direct.GetTabContent"
                            ReloadOnEvent="true"
                            TriggerEvent="activate"
                            RemoveAll="true">
                            <Params>
                                <ext:Parameter Name="tabId" Value="this.id" Mode="Raw" />
                            </Params>
                        </Loader>
                    </ext:Panel>
                </Items>
                <Listeners>
                    <BeforeTabChange Handler="oldTab.removeAll();" />
                </Listeners>
            </ext:TabPanel>  
        </form>
    </body>
    </html>
  9. #9
    Quote Originally Posted by Daniil View Post
    Thank you, we get closer to understand.

    What about the following scenario? A tab Panel can be organized as a custom control.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        [DirectMethod]
        public static string GetTabContent(string parameters)
        {
            Dictionary<string, string> prms = JSON.Deserialize<Dictionary<string, string>>(parameters);
    
            Ext.Net.Label label = new Ext.Net.Label(prms["tabId"] + " " + DateTime.Now.Second);
            return ComponentLoader.ToConfig(label);
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />      
            
            <ext:TabPanel runat="server">
                <Items>
                    <ext:Panel ID="Panel1" runat="server" Title="Tab 1">
                        <Loader 
                            runat="server" 
                            Mode="Component" 
                            DirectMethod="App.direct.GetTabContent"
                            ReloadOnEvent="true"
                            TriggerEvent="activate"
                            RemoveAll="true">
                            <Params>
                                <ext:Parameter Name="tabId" Value="this.id" Mode="Raw" />
                            </Params>
                        </Loader>
                    </ext:Panel>
                    <ext:Panel ID="Panel2" runat="server" Title="Tab 2">
                        <Loader 
                            runat="server" 
                            Mode="Component" 
                            DirectMethod="App.direct.GetTabContent"
                            ReloadOnEvent="true"
                            TriggerEvent="activate"
                            RemoveAll="true">
                            <Params>
                                <ext:Parameter Name="tabId" Value="this.id" Mode="Raw" />
                            </Params>
                        </Loader>
                    </ext:Panel>
                    <ext:Panel ID="Panel3" runat="server" Title="Tab 3">
                        <Loader 
                            runat="server" 
                            Mode="Component" 
                            DirectMethod="App.direct.GetTabContent"
                            ReloadOnEvent="true"
                            TriggerEvent="activate"
                            RemoveAll="true">
                            <Params>
                                <ext:Parameter Name="tabId" Value="this.id" Mode="Raw" />
                            </Params>
                        </Loader>
                    </ext:Panel>
                </Items>
                <Listeners>
                    <BeforeTabChange Handler="oldTab.removeAll();" />
                </Listeners>
            </ext:TabPanel>  
        </form>
    </body>
    </html>
    In your solution is a problem with static keyword of directMethod. I need to operate inside of this directMethod on public nonstatic properties as well as nonstatic methods which is unable with your sample @Daniil.

    And after make your sample to fit my needs I've get nullreference exception of control which I want to load via loader, because there is not perform OnInit control event so all controls inside of control I want to load are null.

    here is sample to reproduce:
    <%@ Page Language="C#" AutoEventWireup="true" %>
    <%@ Import Namespace="Ext.NetTest2.x" %>
    <%@ Register TagPrefix="ext" Namespace="Ext.Net" Assembly="Ext.Net" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
        public class ControlVBox1 : Ext.Net.Container
        {
            private Ext.Net.Panel cntButtons;
            private Ext.Net.Panel mainContainer;
            private Ext.Net.Button btnCreate;
            private Ext.Net.Button btnSearch;
    
            private Ext.Net.GridPanel gridPanelMain;
            private Ext.Net.GridView gridView;
    
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                this.LayoutConfig.Add(new VBoxLayoutConfig {Align = VBoxAlign.Stretch});
                btnCreate = new Ext.Net.Button {ID = this.ID + "_create", Text = "Create", Height = 26, Width = 70};
                btnSearch = new Ext.Net.Button {ID = this.ID + "_search", Text = "Search", Height = 26, Width = 70};
                cntButtons = new Ext.Net.Panel {ID = this.ID + "_buttons"};
                cntButtons.LayoutConfig.Add(new HBoxLayoutConfig {Align = HBoxAlign.Stretch});
                cntButtons.Items.Add(btnCreate);
                cntButtons.Items.Add(btnSearch);
                this.Items.Add(cntButtons);
                gridPanelMain = new GridPanel {ID = this.ID + "_gridPanel", Layout = LayoutType.Fit.ToString()};
                gridView = new Ext.Net.GridView {ID = this.ID + "_gridView"};
                gridPanelMain.View.Add(gridView);
                mainContainer = new Ext.Net.Panel {ID = this.ID + "_main", Flex = 1, Layout = LayoutType.Fit.ToString()};
                mainContainer.Items.Add(gridPanelMain);
                this.Items.Add(mainContainer);
            }
    
            protected override void OnPreRender(EventArgs e)
            {
                base.OnPreRender(e);
                btnCreate.Hidden = false;
            }
    
        }
    
        public string PreviousTabLoaded
        {
            get { return Session["PreviousTabLoaded"] == null ? string.Empty : (string) Session["PreviousTabLoaded"]; }
            set { Session["PreviousTabLoaded"] = value; }
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            int count = 6;
            Ext.Net.Panel panel;
            while (count != 0)
            {
                panel = new Ext.Net.Panel{ID="panel"+count,Title = "Tab"+count,Layout = LayoutType.Fit.ToString()};
                panel.Loader = new ComponentLoader { ID = panel.ID + "_loader", Mode = LoadMode.Component, RemoveAll = true, ReloadOnEvent = true, TriggerEvent = "activate", DirectMethod = "#{DirectMethods}.GetTabContent",Params = {new Ext.Net.Parameter("tabId","this.id",ParameterMode.Raw)}};
                if (string.IsNullOrEmpty(PreviousTabLoaded))
                {
                    PreviousTabLoaded = panel.ID;
                    tPanel.Items.Add(panel);
                }
                else if (PreviousTabLoaded.Contains(panel.ID))
                {
                    tPanel.Items.Add(panel);
                    //tPanel.ActiveTab = panel;
                }
                else
                {
                    tPanel.Items.Add(panel);
                }
                count--;
            }
        }
        [DirectMethod]
        public string GetTabContent(string parameters)
        {
            Dictionary<string, string> prms = JSON.Deserialize<Dictionary<string, string>>(parameters);
    
            ControlVBox1 control = new ControlVBox1 { ID = prms["tabId"] + "_control" };
            Ext.Net.X.Mask.Hide();
            return ComponentLoader.ToConfig(control);
        }
    
    
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager runat="server" IDMode="Legacy" ScriptMode="Development"></ext:ResourceManager>
        <ext:Viewport runat="server">
            <LayoutConfig>
                <ext:FitLayoutConfig runat="server"/>
            </LayoutConfig>
            <Items>
                <ext:Container runat="server" ID="mainContainer">
                    <LayoutConfig>
                        <ext:VBoxLayoutConfig runat="server" Align="Stretch"/>
                    </LayoutConfig>
                    <Items>
                        <ext:Panel runat="server" ID="buttons" Height="30">
                            <Items>
                                <ext:Hidden runat="server" ID="tabId"></ext:Hidden>
                                <ext:Button runat="server" ID="button" Text="button"></ext:Button>
                            </Items>
                        </ext:Panel>
                        <ext:Panel runat="server" ID="mainCont" Flex="1" Layout="FitLayout">
                            <Items>
                                <ext:TextField runat="server"></ext:TextField>
                                <ext:TextField runat="server"></ext:TextField>
                            </Items>
                        </ext:Panel>
                        <ext:Panel runat="server" Title="List" ID="southPanel" MinHeight="200" MaxHeight="300" Flex="1" Collapsible="True" CollapseMode="Default" Collapsed="True" >
                            <Items>
                                <ext:TabPanel ID="tPanel" AutoHeight="True" runat="server" Border="false" ActiveIndex="0" Layout="FitLayout" >
                                    <Listeners>
                                        <BeforeTabChange Handler="oldTab.removeAll();" />
                                        <TabChange Handler="Ext.net.Mask.show({ msg : 'Trwa ładowanie listy...', el : newTab });"></TabChange>
                                    </Listeners>
                                </ext:TabPanel>
                            </Items>
                        </ext:Panel>
                    </Items>
                </ext:Container>
            </Items>
        </ext:Viewport>
    </body>
    </html>
    Last edited by ViDom; May 24, 2013 at 6:37 AM.
  10. #10
    There is an issue in Ext.NET.

    ComponentLoader.ToConfig() causes a control's OnPreRender executed prior to its OnInit. We are trying to fix it.

    We found this severe issue due to your test case. Thank you.
    Last edited by Daniil; May 24, 2013 at 3:32 AM.
Page 1 of 3 123 LastLast

Similar Threads

  1. [CLOSED] First Request taking too much time to load page
    By shaileshsakaria in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 06, 2013, 7:56 PM
  2. How can i do learn GridPanel load time
    By fatihunal in forum 1.x Help
    Replies: 2
    Last Post: Feb 01, 2012, 8:09 PM
  3. [CLOSED] performance when the page load first time
    By lonely7345 in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Oct 06, 2011, 6:06 PM
  4. [URGENT] General Page Load time
    By vs.mukesh in forum 1.x Help
    Replies: 0
    Last Post: Mar 30, 2011, 5:01 AM
  5. Replies: 7
    Last Post: Sep 22, 2010, 8:07 AM

Tags for this Thread

Posting Permissions