PDA

View Full Version : [CLOSED] Dynamically create Ext: Tab at runtime.



admiral
Jul 19, 2008, 8:36 PM
Hi Coolite Team,

I just started out exploring the toolkit and I was wondering if there's a way to dynamically creating a new tab when an ASP LinkButton control is clicked(server-side).

I was playing with the ViewPort sample found here (http://sandbox.ext.net/ViewPort/ViewPort.aspx) and I wanted to add an ASP LinkButton inside the Navigation panel and when it's clicked, I would create a new tab inside the <Center> of ViewPort by invoking this event:



protected void LinkButton1_Click(object sender, EventArgs e)
{
Tab fees = new Tab();
fees.Closable = true;
fees.Title = "Fees";
fees.AutoLoad = "Fees.aspx";

center.Items.Add(fees);
}

geoffrey.mcgill
Jul 20, 2008, 2:05 PM
Hi admiral,

Welcome aboard!

Inside the <Center> region you would need to first add a <ext:TabPanel> control, then add you Tab to the TabPanel.

The following sample demonstrates how to dynamically add a TabPanel and Tab to the Center region of a ViewPort.

Example


// Make TabPanel
TabPanel tp= new TabPanel();
tp.ID = "CenterPanel";
tp.ActiveTab = 0;

// Make Tab
Tab tab1 = new Tab();
tab1.ID = "Tab1";
tab1.Title = "Close Me";
tab1.Closable = true;
tab1.Border = false;
tab1.BodyStyle = "padding:6px;";
tab1.Html = "Hello...";

// Add Tab to TabPanel
tp.Tabs.Add(tab1);

// Add TabPanel to the <Center> region
layout.Center.Items.Add(tp);

The above code was based on the Complex BorderLayout sample available at the following location, see http://sandbox.ext.net/Layout/BorderLayout/ComplexLayout.aspx.

Hope this helps.