[CLOSED] TabPanel tabs activating differently if remove tabs

  1. #1

    [CLOSED] TabPanel tabs activating differently if remove tabs

    Hi,

    In my web application I need to add tabs to tab panel at bottom of the form and based on tab selection the required information related to selected tab will show in center panel. For demo purpose I have added one toolbar at top of the form as showing in the image. In left textfield enter number of tabs required, and click Open forms button. The number of tabs will add at bottom. Just click on each tab and see the tab related info will show in the center panel.
    Now add any tab number (without zeros) in right textfield in toolbar and click "Delete this number form", it will delete the entered number tab. Once delete any tab, I want to load ("ExtSampleForm.aspx"). It is working fine if we add extreme tab number and click "Delete this...", but it is not working correctly if we enter first tab number to delete. It is loading all tabs info form one by one and finally shows one tab info form, but I want to show only "ExtSampleForm.aspx" all the time when delete any tab.

    The main form code...
    
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.pnlMain.LoadContent("ExtSampleForm.aspx");
            }
        }
        
        public void OpenAllForms(object sender, DirectEventArgs e)
        {
            Session["AppListToOpen"] = null;
            SortedList sAppList = new SortedList();
            for (int i = 1; i <= Convert.ToInt32(txtNoOfForms.Text); i++)
            {
                sAppList.Add(i.ToString("000000"), i.ToString("000000"));
            }
    
            Session["AppListToOpen"] = sAppList;
            Session["PresetApp"] = 0;
            LoadAppTabs();
            CheckLoadingFile();
            LoadRequiredPage();
        }
    
        public void DeleteEnteredNumber(object sender, DirectEventArgs e)
        {
            
            SortedList sAppList = (SortedList)Session["AppListToOpen"];
            int keyVal = Convert.ToInt32(txtLoanNumber.Text);
    
            sAppList.Remove(keyVal.ToString("000000"));
            Session["APPLICATION_ID"] = 0;
            Session["PresetApp"] = 0;
            Session["AppListToOpen"] = sAppList;
    
            LoadSearchPage();
        }
    
    
        public void LoadAppTabs()
        {
            Ext.Net.Panel pnlApp;        
            
            SortedList sAppList;
    
            tbApplications.RemoveAll();
    
            if (Session["AppListToOpen"] != null)
            {
                sAppList = (SortedList)Session["AppListToOpen"];
                for (int i = 0; i < sAppList.Count; i++)
                {
                    if (Ext.Net.X.GetCmp("App" + sAppList.GetKey(i).ToString()) == null)
                    {
                        pnlApp = new Ext.Net.Panel();
                        pnlApp.ID = "App" + sAppList.GetKey(i).ToString();
                        if (sAppList[sAppList.GetKey(i).ToString()].ToString().Trim().Length > 0)
                            pnlApp.Title = sAppList[sAppList.GetKey(i).ToString()].ToString();
                        else
                            pnlApp.Title = sAppList.GetKey(i).ToString();
                        pnlApp.Closable = true;
                        pnlApp.Listeners.Close.Handler = "CloseAppPanel('" + sAppList.GetKey(i).ToString() + "');";
                        pnlApp.Listeners.Activate.Handler = "OpenLoanSpecifcPages('" + sAppList.GetKey(i).ToString() + "');";
                        pnlApp.AddTo(tbApplications);
                    }
                }
            }
        }
    
        [DirectMethod()]
        public void LoadSearchPage()
        {
            hidUrl.Text = "ExtSampleForm.aspx";
            this.pnlMain.LoadContent("ExtSampleForm.aspx");
            LoadAppTabs();
            CheckLoadingFile();
            LoadRequiredPage();
        }
        
        [DirectMethod]
        public void CloseApplication(string appid)
        {
            SortedList sAppList;
    
            if (Session["AppListToOpen"] != null)
            {
                sAppList = (SortedList)Session["AppListToOpen"];
                if (sAppList.ContainsKey(appid))
                {
                    sAppList.Remove(appid);
                    Session["CloseAppId"] = appid;
                    if (sAppList.Count > 0)
                        Session["AppListToOpen"] = sAppList;
                    else
                        Session["AppListToOpen"] = null;
                }
            }
            else
                sAppList = new SortedList();
    
            CheckLoadingFile();
    
            if (sAppList.Count > 0)
            {
                if (hidUrl.Text == "ExtCenterPanel.aspx")
                {
                    int LastAppId;
    
                    LastAppId = Convert.ToInt32(sAppList.GetKey(sAppList.Count - 1).ToString());
    
                    if (Session["APPLICATION_ID"].ToString() == appid)
                    {
                        Session["APPLICATION_ID"] = LastAppId;
                        Session["PresetApp"] = sAppList.GetKey(sAppList.Count - 1).ToString();
                        LoadRequiredPage();
                    }
                    else
                    {
                        Session["APPLICATION_ID"] = Session["PresetApp"].ToString();
                    }                
                }
            }
            else
            {
                if (hidUrl.Text == "ExtSampleForm.aspx" || hidUrl.Text == "ExtCenterPanel.aspx")
                {
                    if (hidUrl.Text != "ExtSampleForm.aspx")
                    {
                        hidUrl.Text = "ExtSampleForm.aspx";
                        pnlMain.LoadContent("ExtSampleForm.aspx");                   
                    }
                }
    
                pnlFooter.Hide();
                Session["APPLICATION_ID"] = 0;
                Session["PresetApp"] = "0";
    
                vpCommonPage.DoLayout();
            }
        }
    
        public void LoadRequiredPage()
        {
            
            string AppId = "0";
    
            if (Session["APPLICATION_ID"] != null)
                AppId = Session["APPLICATION_ID"].ToString();
    
            if (Convert.ToInt32(AppId) == 0)
                AppId = Session["PresetApp"].ToString();
    
            if (Convert.ToInt32(AppId) > 0)
            {           
                if (Convert.ToInt32(AppId) > 0)
                {
                    pnlMain.LoadContent("ExtCenterPanel.aspx");
                    hidUrl.Text = "ExtCenterPanel.aspx";
                }
                else
                {
                    if (Session["AppListToOpen"] != null)
                    {
                        SortedList sAppList;
                        sAppList = (SortedList)Session["AppListToOpen"];
                        if (sAppList.Count <= 0)
                        {
                            pnlFooter.Hide();
                            Session["APPLICATION_ID"] = 0;
                            Session["PresetApp"] = "0";
                        }
                    }
                    else
                    {
                        pnlFooter.Hide();
                        Session["APPLICATION_ID"] = 0;
                        Session["PresetApp"] = "0";
                    }
                }
            }
            else
            {
                if (Session["AppListToOpen"] != null)
                {
                    SortedList sAppList;
                    sAppList = (SortedList)Session["AppListToOpen"];
                    if (sAppList.Count <= 0)
                    {
                        pnlFooter.Hide();
                        Session["APPLICATION_ID"] = 0;
                        Session["PresetApp"] = "0";
                    }
                }
                else
                {
                    pnlFooter.Hide();
                    Session["APPLICATION_ID"] = 0;
                    Session["PresetApp"] = "0";
                }
            }
    
    
        }
    
        [DirectMethod]
        public void pnlLoanTabsActivate(string AppId)
        {
    
            Session["APPLICATION_ID"] = AppId;
            ShowPanelActiveInactive();
        }
    
        public void ShowPanelActiveInactive()
        {
            SortedList sAppList = new SortedList();
            if (Session["AppListToOpen"] != null)
                sAppList = (SortedList)Session["AppListToOpen"];
    
            string AppId = Session["APPLICATION_ID"].ToString();
    
            if (Session["PresetApp"] != null)
            {
                if (hidUrl.Text == "ExtCenterPanel.aspx")
                {
                    if (Session["PresetApp"].ToString() != AppId)
                    {
                        Session["PresetApp"] = AppId;
                        LoadRequiredPage();
                    }
                }
                else
                {
                    LoadRequiredPage();
                }
            }
            else
            {
                Session["PresetApp"] = AppId;
                LoadRequiredPage();
            }
    
        }
    
        public void CheckLoadingFile()
        {
            SortedList sLoansToOpen;
    
            if (Session["AppListToOpen"] != null)
            {
                sLoansToOpen = (SortedList)Session["AppListToOpen"];
                if (sLoansToOpen.Count > 0)
                {
                    pnlFooter.Show();
                }
                else
                {
                    if (hidUrl.Text != "ExtSampleForm.aspx")
                    {
                        hidUrl.Text = "ExtSampleForm.aspx";
                        pnlMain.LoadContent("ExtSampleForm.aspx");
                        pnlFooter.Hide();
                    }
                    pnlFooter.Hide();
                    Session["APPLICATION_ID"] = 0;
                    Session["PresetApp"] = "0";
    
                }
            }
            else
            {
                if (hidUrl.Text == "ExtSampleForm.aspx" || hidUrl.Text == "ExtCenterPanel.aspx")
                {
                    if (hidUrl.Text != "ExtSampleForm.aspx")
                    {
                        hidUrl.Text = "ExtSampleForm.aspx";
                        pnlMain.LoadContent("ExtSampleForm.aspx");
                        pnlFooter.Hide();
                        Session["APPLICATION_ID"] = 0;
                        Session["PresetApp"] = "0";
                    }
                }
                else
                {
                    pnlFooter.Hide();
                    Session["APPLICATION_ID"] = 0;
                    Session["PresetApp"] = "0";
                }
            }
            vpCommonPage.DoLayout();
        }
    </script>
    
    <script language="javascript" type="text/javascript">
    
        var CloseAppPanel = function (appid) {
            Ext.net.DirectMethods.CloseApplication(appid);
        }
    
        var OpenLoanSpecifcPages = function (appid) {        
            Ext.net.DirectMethods.pnlLoanTabsActivate(appid);
        }
    
        function loadAfterDelete() {
            Ext.net.DirectMethods.LoadSearchPage();
        }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Viewport runat="server" Layout="border" ID="vpCommonPage">
            <Items>
                <ext:Panel ID="pnlTops" runat="server" Region="North" Height="30" Border="false"
                    BodyStyle="background-color:#424E5A">
                    <TopBar>
                        <ext:Toolbar ID="tbPanel" runat="server">
                            <Items>
                                <ext:TextField ID="txtNoOfForms" runat="server" Text="5">
                                </ext:TextField>
                                <ext:ToolbarSeparator />
                                <ext:Button ID="btnOpenTabs" runat="server" Text="Open forms">
                                <DirectEvents>
                                <Click OnEvent="OpenAllForms"></Click>
                                </DirectEvents>
                                </ext:Button>
                                <ext:ToolbarFill />
                                <ext:TextField ID="txtLoanNumber" runat="server" ></ext:TextField>
                                <ext:ToolbarSeparator />
                                <ext:Button ID="btnDelete" runat="server" Text="Delete This Number Form">
                                <DirectEvents>
                                <Click OnEvent="DeleteEnteredNumber" ></Click>
                                </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Items>
                    </Items>
                </ext:Panel>
                <ext:Panel ID="pnlMain" runat="server" Padding="5" Region="Center" BodyStyle="background-color:#C9D9ED"
                    Border="false">
                    <AutoLoad Mode="IFrame" NoCache="true" ShowMask="true" MaskMsg="Loading..." />
                </ext:Panel>
                <ext:Panel ID="pnlFooter" runat="server" Region="South" Height="25" Margins="0,0,0,0"
                    Border="false" Hidden="true" BodyStyle="background-color:#C9D9ED">
                    <Items>
                        <ext:TabPanel ID="tbApplications" runat="server" Height="25" AnchorHorizontal="100%"
                            Border="false" IDMode="Explicit" EnableTabScroll="true" Plain="true">
                            <Plugins>
                                <ext:TabScrollerMenu PageSize="5">
                                </ext:TabScrollerMenu>
                            </Plugins>
                            <Items>
                            </Items>
                        </ext:TabPanel>
                    </Items>
                </ext:Panel>
            </Items>
        </ext:Viewport>
        <ext:Hidden ID="hidUrl" Text="" runat="server">
        </ext:Hidden>
        </form>
    </body>
    </html>
    The center panel ("ExtCenterPanel.aspx") code ...
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                lblAppNumber.Text = Session["APPLICATION_ID"].ToString();
            }
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Viewport runat="server" Layout="border" ID="vpCommonPage">
            <Items>
            <ext:Panel ID="pnlCenter" runat="server" Padding="5" Region="Center" BodyStyle="background-color:#C9D9ED"
                    Border="false">
                    <Items>
                    <ext:Label ID="lblAppNumber" runat="server" Text="label"></ext:Label>
                    </Items>
                </ext:Panel>
            </Items>
            </ext:Viewport>
        </form>
    </body>
    </html>
    And Sample form ("ExtSampleForm.aspx") code...

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            Sample Form
        </div>
        </form>
    </body>
    </html>
    Click image for larger version. 

Name:	TabPanels.PNG 
Views:	46 
Size:	10.8 KB 
ID:	5824
    Last edited by Daniil; Mar 21, 2013 at 7:58 AM. Reason: [CLOSED]
  2. #2
    Hello!

    Sorry, but I don't quite understand your code. Can you provide simplified version of it?

    http://forums.ext.net/showthread.php?3440
    http://forums.ext.net/showthread.php?10205
  3. #3
    Hi Baidaly,

    I am just attaching sample project. Please open and run "ExtTabPanelTest.aspx". Then click on "Open Forms", tabs will show at bottom, click on any tab, that tab number will show in center. I want to delete tabs from server-side. To do this enter tab number "5" or "4" or "3"...at right side textfield at top toolbar and click on "Delete this number Form". You can see the tab disappear and the default form "ExtSampleForm.aspx" will load in center panel. If enter extreme right tab number like "5" to delete, the functionality is working fine. If enter extreme left tab number like "1" the center panel is not loading with default form "ExtSampleForm.aspx", because "OpenLoanSpecifcPages" listener is firing for each tab. How to avoid this?
    ExtTabPanelTest.zip

    Quote Originally Posted by Baidaly View Post
    Hello!

    Sorry, but I don't quite understand your code. Can you provide simplified version of it?

    http://forums.ext.net/showthread.php?3440
    http://forums.ext.net/showthread.php?10205
  4. #4
    Thank you for your project.

    I was able to run your code, but problem is that it's difficult to understand where is the problems of Ext.NET and where is the problems of your application's logic. For this reason we asking to provide simplified examples without unnecessary details to reproduce.
  5. #5
    Hi Baidaly,

    I am attaching simplified project. Please check it. I just added "System.Threading.Thread.Sleep(1000)" to view how tabs are activating if we remove from left to right or in between. Select the tab and enter that selected tab number in delete text field and click delete. The sample form will load without any issue if we delete extreme right tab, but the sample form is not loading if any other tab select to delete. Just run this and you can come to know that.
    ExtTabPanelTest.zip
  6. #6
    Hi @rnachman,

    Should "Delete This Number Form" delete a single tab?

    I see that it deletes all the tabs and recreates again with the specified one.
    tbApplications.RemoveAll();
    ...
    It is very expensive and, maybe, there is some logical error in this scenario which causes the undesired behavior you described.

    I can suggest to review the implementation not to remove all the tabs if you need to remove just one.
  7. #7
    Hi Daniil,

    Ok I can remove that, but all tabs I need to create from server side. How to identify the tab exists in TabPanel from server-side.
    tbApplications.FindControl("App" + sAppList.GetKey(i).ToString()) is always returning null. tbApplications.Items.Count is always returning 0.
    I want to verify tab existed or not before add tab to tabpanel.


    Quote Originally Posted by Daniil View Post
    Hi @rnachman,

    Should "Delete This Number Form" delete a single tab?

    I see that it deletes all the tabs and recreates again with the specified one.
    tbApplications.RemoveAll();
    ...
    It is very expensive and, maybe, there is some logical error in this scenario which causes the undesired behavior you described.

    I can suggest to review the implementation not to remove all the tabs if you need to remove just one.
  8. #8
    As far as I can see you are keeping this information in the Session, aren't?

    Well, if a control is rendered during one AJAX request, it is not presented during another one and page doesn't know about that control.

    You could send these information from client or keep it on server if a Store like Session. Well, as you do.

Similar Threads

  1. [CLOSED] Move tabs Tabs Style Google Chrome
    By majunior in forum 1.x Premium Help
    Replies: 7
    Last Post: Apr 30, 2013, 1:58 PM
  2. Dynamic tabs
    By Aswini Ladish in forum 1.x Help
    Replies: 2
    Last Post: Dec 20, 2012, 5:40 AM
  3. Replies: 2
    Last Post: Jan 19, 2012, 1:42 PM
  4. Not able to add/remove tabs using DirectMethod
    By paul-2011 in forum 1.x Help
    Replies: 3
    Last Post: Mar 16, 2011, 11:17 PM
  5. Tabs "vanish" in IE
    By filipator in forum 1.x Help
    Replies: 1
    Last Post: Apr 05, 2009, 4:42 AM

Tags for this Thread

Posting Permissions