Jun 13, 2013, 11:40 AM
Auto load MenuItem to MenuPanel in MVC
Hi,
I have panel with accordion layout.
I use ComponentLoader for auto loading MenuPanel's from partial view.
How on expand MenuPanel auto load MenuItem's from partial view?
I found working solution:
Menu.cshtml
I have panel with accordion layout.
I use ComponentLoader for auto loading MenuPanel's from partial view.
How on expand MenuPanel auto load MenuItem's from partial view?
I found working solution:
Menu.cshtml
@{ var X = Html.X(); }
@(X.MenuPanel()
.ID(id)
.Title(module.Name)
.SaveSelection(false)
.DirectEvents(e => {
e.Expand.Url = Url.Action("ModuleMenuItems");
e.Expand.ExtraParams.Add(new { containerId = id, moduleId = module.Id });
e.Expand.EventMask.ShowMask = true;
e.Expand.EventMask.Target = MaskTarget.This;
e.Expand.Single = true;
})
//.Loader(X.ComponentLoader()
// .Url(Url.Action("ModuleMenuItems"))
// .Mode(LoadMode.Script)
// .Params(new {
// containerId = id,
// moduleId = module.Id
// })
// .LoadMask(m => m.ShowMask = true)
//)
)
HomeController.cspublic ActionResult ModuleMenuItems(string containerId, int moduleId)
{
var moduleMenuItems = Mapper.Map<IEnumerable<ModuleMenuItemViewModel>>(repository.GetModuleMenuItems(moduleId));
/*return this.PartialExtView(
containerId: containerId,
mode: Ext.Net.RenderMode.AddTo,
wrapByScriptTag: false,
model: moduleMenuItems
);*/
/*var panel = this.GetCmp<MenuPanel>(containerId);
panel.Menu.Items.Add(new MenuItem("item1"));*/
foreach (var item in moduleMenuItems) {
var mi = new MenuItem {
Text = item.Text,
Icon = Icon.ApplicationForm
};
mi.AddTo(string.Format("Ext.getCmp('{0}').menu", containerId));
}
return this.Direct();
}
But maybe anybody know better solution?
Last edited by anpv; Jun 14, 2013 at 10:43 AM.