Jul 04, 2011, 2:52 PM
Add Panels with Autoload to an accordion
Hello,
I'm creating a quick MVC application. For the time being I managed to add Panels to a TabPanel and autoload content into them... apparently the crux of the problem was that to use RenderMode.RenderTo in the controller when creating the partial view, it is important to pass the body.id of the Panel where rendering to.
I'm now trying to accomplish the same thing with an accordion but creating the accordion menu at page load time does not give me the option of specifying the target container as the panel body id. In the example:
As an example here is the controller:
Regards.
I'm creating a quick MVC application. For the time being I managed to add Panels to a TabPanel and autoload content into them... apparently the crux of the problem was that to use RenderMode.RenderTo in the controller when creating the partial view, it is important to pass the body.id of the Panel where rendering to.
I'm now trying to accomplish the same thing with an accordion but creating the accordion menu at page load time does not give me the option of specifying the target container as the panel body id. In the example:
<script runat="server">
public void Page_Load(object sender, EventArgs e)
{
foreach (var item in Model.SubSystems)
{
var panel = new Ext.Net.Panel(item.DisplayName, Icon.PageWhiteGear) { ID = "detailsPanel" + item.Id, Collapsed = true, Height = 300, Margins = "10" };
panel.AutoLoad.Url = "/ConfigTool/Details/" + item.Id;
panel.AutoLoad.Params.Add(new Ext.Net.Parameter("containerId", panel.ID));
this.Accordion.Items.Add(panel);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Index</title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Panel ID="MainWindow" runat="server" Title="Sub-Systems" Padding="10">
<Items>
<ext:AccordionLayout ID="Accordion" runat="server" Animate="true">
<Items>
</Items>
</ext:AccordionLayout>
</Items>
</ext:Panel>
I can see the 3 calls to the appropriate controller and in the end the 3 partial view are appearing on the page but they are outside the accordion... kind of in the middle between the first and second accordion panel and indeed they don't hide and show when the accordions are collapsed or expanded.As an example here is the controller:
public ActionResult Details(int id, string containerId)
{
var pr = new Ext.Net.MVC.PartialViewResult(containerId, Ext.Net.RenderMode.RenderTo);
pr.ViewData = new ViewDataDictionary(new MyModel());
return pr;
}
and the Details partial view:<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
public void Page_Load(object sender, EventArgs e)
{
this.DetailStore.DataSource = ViewData.Model;
this.DetailStore.DataBind();
}
</script>
<ext:GridPanel ID="GridPanel2" runat="server" Anchor="100%" Layout="AnchorLayout">
<Store>
<ext:Store ID="DetailStore" runat="server">
[..... an ArrayReader here .....]
</ext:Store>
</Store>
<ColumnModel runat="server" DefaultWidth="200">
<Columns>
[..... a ColumnSet here .....]
</Columns>
</ColumnModel>
</ext:GridPanel>
Any idea on how to force the 3 individual grids to stay each in its own accordion panel?Regards.