Jun 24, 2017, 9:15 PM
[CLOSED] Panel in portal not updating content
Hi
I am trying to dynamically load content into the panel based on the "Portal Template" provided in the Ext.net exampled page. I am following the load method provided whereby a component loader is created srver side and a this.direct() is returned but the panel does not update with the desired content. If I load the page with a static component loader it does however work. Can you please advise.
I have attached the View and necessary controller code in the attachments. The method I am having a problem with is the "LoadContent" method of the PortalController Class. You will see in the view code I dynamically give the content panels id's since they are constructed from a model.
View below with the method generateTabPanel() which dynamically generates tabs and associated menus. The controller code is below the view.
I am trying to dynamically load content into the panel based on the "Portal Template" provided in the Ext.net exampled page. I am following the load method provided whereby a component loader is created srver side and a this.direct() is returned but the panel does not update with the desired content. If I load the page with a static component loader it does however work. Can you please advise.
I have attached the View and necessary controller code in the attachments. The method I am having a problem with is the "LoadContent" method of the PortalController Class. You will see in the view code I dynamically give the content panels id's since they are constructed from a model.
View below with the method generateTabPanel() which dynamically generates tabs and associated menus. The controller code is below the view.
@using Ext.Net.Utilities
@model GemsFraudManagementTool.Models.PortalModel
@{
Layout = null;
var X = Html.X();
}
@* ReSharper disable once SuggestVarOrType_SimpleTypes *@
@functions
{
private List<Panel> GenerateTabPanel()
{
var panels = new List<Panel>();
foreach (var tab in Model.TabElements.OrderBy(x => x.Ordinal))
{
var panel = new Panel {Title = tab.DisplayName, Layout = LayoutType.HBox.ToString()};
panel.LayoutConfig.Add(new HBoxLayoutConfig() {Align = HBoxAlign.Stretch});
//now generate menu items for specific tab
var menuItems = new List<MenuItem>();
string contentPanelId = string.Format("{0}_contentPanel", tab.Ordinal);
foreach (var menuElement in tab.MenuElements.OrderBy(x => x.Ordinal))
{
var menuItem = new MenuItem() {Text = menuElement.DisplayName};
menuItem.DirectEvents.Click.Url = Url.Action("LoadContent");
menuItem.DirectEvents.Click.ExtraParams.Add(new Parameter("url", menuElement.Url));
menuItem.DirectEvents.Click.ExtraParams.Add(new Parameter("mainComponentPanelId", contentPanelId));
menuItems.Add(menuItem);
}
var menuPanel = new MenuPanel {Width = 215, Border = false, SelectedIndex = 0};
menuPanel.Menu.Add(menuItems);
menuPanel.Collapsible = true;
menuPanel.CollapseDirection = Direction.Left;
var contentPanel = new Panel
{
Flex = 1, Border = false, Header = false, ID = contentPanelId
};
//contentPanel.Loader = new ComponentLoader() {Url = Url.Action("Index", "Providers"),
// DisableCaching = true, AutoLoad = true};
//contentPanel.Html = String.Format("Content panel with id {1} added at: {0}",DateTime.Now,contentPanelId);
//contentPanel.LoadContent("Providers",true);
panel.Items.Add(menuPanel);
panel.Items.Add(contentPanel);
panels.Add(panel);
}
return panels;
}
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width"/>
<title></title>
<script></script>
</head>
<body>
@(X.ResourceManager())
@(X.Viewport()
.Layout(LayoutType.VBox)
.LayoutConfig(new VBoxLayoutConfig {Align = VBoxAlign.Stretch})
.Items(
X.Panel()
.ItemID("north")
//.Height(150)
.Header(false)
.Border(false)
.TopBar(
X.Toolbar().Items(items =>
{
items.Add(new ToolbarTextItem {Text = "You are logged in as:"});
items.Add(new Hyperlink {Text = "Jack Smith"});
items.Add(new ToolbarSpacer());
items.Add(new ToolbarSeparator());
items.Add(new ToolbarSpacer());
items.Add(new Hyperlink {Text = "Logout"});
items.Add(new ToolbarSpacer());
items.Add(new ToolbarSeparator());
items.Add(new ToolbarSpacer());
items.Add(new Hyperlink {Text = "My Profile"});
items.Add(new ToolbarSpacer());
items.Add(new ToolbarSeparator());
items.Add(new ToolbarSpacer());
items.Add(new Hyperlink {Text = "Messages (3)"});
items.Add(new ToolbarSpacer());
items.Add(new ToolbarSeparator());
items.Add(new ToolbarSpacer());
items.Add(new Hyperlink {Text = "Help"});
items.Add(new ToolbarFill());
items.Add(new Button
{
Text = "My Account",
MarginSpec = "0 20 0 0",
Listeners =
{
Click =
{
Handler = "Ext.Msg.alert(Ext.getBody().getSize().width.toString());"
}
},
Menu =
{
new Menu
{
Items =
{
new MenuItem {Text = "Settings", Icon = Icon.Cog},
new MenuItem {Text = "About", Icon = Icon.Information}
}
}
}
});
}
)
)
.Layout(LayoutType.Card)
.Items(
X.Container()
.Layout(LayoutType.HBox)
.LayoutConfig(new HBoxLayoutConfig {Align = HBoxAlign.Middle})
.Items(items => { items.Add(new Image {ImageUrl = "~/Resources/Portal/GEMS-logo.jpg", Width = 142, Height = 100}); }
)
),
X.TabPanel()
.Flex(1)
.ActiveTabIndex(1)
.Items(GenerateTabPanel())
))
</body >
</
html>
Controller Codeusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ext.Net;
using Ext.Net.MVC;
using GemsFraudManagementTool.Models;
namespace GemsFraudManagementTool.Controllers
{
public class PortalController : Controller
{
// GET: Portal
public ActionResult Index()
{
return View(PortalModel.InitializePortalModel());
}
public ActionResult LoadContent(string url,string mainComponentPanelId)
{
var panel = X.GetCmp<Panel>(mainComponentPanelId);
//panel.Html = DateTime.Now.ToLongTimeString();
var componentLoader = new ComponentLoader();
componentLoader.DisableCaching = true;
componentLoader.Url = Url.Action("Index", "Providers");
componentLoader.LoadMask.ShowMask = true;
componentLoader.SuspendScripting();
panel.Loader = componentLoader;
panel.LoadContent();
return this.Direct();
}
}
}
Last edited by fabricio.murta; Jul 14, 2017 at 4:11 PM.
Reason: no feedback from the user in 7+ days