Auto load MenuItem to MenuPanel in MVC

  1. #1

    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
    @{ 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.cs
    public 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.

Similar Threads

  1. Replies: 3
    Last Post: Sep 03, 2012, 4:01 AM
  2. Changing color or image of MenuItem inside MenuPanel
    By venu.sn2009 in forum 1.x Help
    Replies: 2
    Last Post: Jun 15, 2011, 10:02 AM
  3. [CLOSED] How to highlight menuitem in Menupanel
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 06, 2011, 3:24 PM
  4. [CLOSED] [1.0] Deselect menuItem in MenuPanel
    By x1000 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 03, 2010, 4:45 AM
  5. [CLOSED] [1.0] Problem in AccordionLayout, MenuPanel, MenuItem
    By miguelon in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 22, 2009, 2:48 PM

Tags for this Thread

Posting Permissions