[CLOSED] Dynamic menu containing button menu display problem on click

  1. #1

    [CLOSED] Dynamic menu containing button menu display problem on click

    Hi guys,

    I have a problem with my dynamic menu which contains an button with menu. So when I click on my dynamic menu, "Menu 1" appears but when I click on "Menu 1", it desappears.

    I want my "menu 1" to not desappers on "menu 1" click but only if i click on subItem of "Menu 1". How can I do this ?

    Here is my test example

    index.cshtml
    @Html.Action("TestPartial")
    TestPartial.cshtml
    @using Ext.Net;
    @using Ext.Net.MVC;
    
    @model Button.Config
    
    @(
     Html.X().Button(Model)
    )
    TestController.cs
            public ActionResult Index()
            {
                return View();
            }
    
            public ActionResult LoadMenu()
            {
                List<Ext.Net.ComponentBase> items = new List<Ext.Net.ComponentBase>();
    
                Button privateButton = new Button
                {
                    Text = "Menu 1"
                };
    
                Menu menu = new Menu();
                privateButton.Menu.Add(menu);
                
                items.Add(privateButton);
    
                for (int i = 1; i < 6; i++)
                {
                    MenuItem subItem = new MenuItem();
                    subItem.Text = string.Format("Item {0}", i);
                    menu.Add(subItem);
                }
    
    
    
                return Content(ComponentLoader.ToConfig(items));
            }
    
            public ActionResult TestPartial()
            {
                Button.Config buttonConfig = new Button.Config
                {
                    Text = "Dynamic menu"
                };
    
                Menu menu = new Menu();
    
                MenuItem item = new MenuItem();
                item.IconCls = "x-loading-indicator";
                item.CanActivate = false;
                item.HideOnClick = false;
    
                menu.Add(item);
    
                menu.Loader = new ComponentLoader { Mode = LoadMode.Component, Url = "Test/LoadMenu", RemoveAll = true, TriggerEvent = "show", ReloadOnEvent = true };
    
                buttonConfig.Menu.Add(menu);
    
                return PartialView(buttonConfig);
            }
    Last edited by Daniil; Mar 04, 2014 at 2:26 PM. Reason: [CLOSED]
  2. #2
    Hi @Tactem,

    You are doing the following:
    @(X.Button().Text("Button")
        .Menu(X.Menu()
            .Items(
                X.Button()
                    .Text("Sub Button")
                    .Menu(
                        X.Menu().Items(
                            X.MenuItem().Text("MenuItem 1"),
                            X.MenuItem().Text("MenuItem 2")
                        )                    
                    )
            )    
        )
    )
    I.e. you are putting a Button as a Menu's item. I would recommend not to do that.

    The following is better:
    @(X.Button().Text("Button")
        .Menu(X.Menu()
            .Items(
                X.MenuItem()
                    .Text("Sub menu")
                    .Menu(
                        X.Menu().Items(
                            X.MenuItem().Text("MenuItem 1"),
                            X.MenuItem().Text("MenuItem 2")
                        )                    
                    )
            )    
        )
    )
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @Tactem,

    You are doing the following:
    @(X.Button().Text("Button")
        .Menu(X.Menu()
            .Items(
                X.Button()
                    .Text("Sub Button")
                    .Menu(
                        X.Menu().Items(
                            X.MenuItem().Text("MenuItem 1"),
                            X.MenuItem().Text("MenuItem 2")
                        )                    
                    )
            )    
        )
    )
    I.e. you are putting a Button as a Menu's item. I would recommend not to do that.

    The following is better:
    @(X.Button().Text("Button")
        .Menu(X.Menu()
            .Items(
                X.MenuItem()
                    .Text("Sub menu")
                    .Menu(
                        X.Menu().Items(
                            X.MenuItem().Text("MenuItem 1"),
                            X.MenuItem().Text("MenuItem 2")
                        )                    
                    )
            )    
        )
    )
    I know Daniil, I just want to have the direction of menu Down instead of having it to right. Is it possible ?
  4. #4
    There is the MenuAlign setting.
    @(X.Button().Text("Button")
        .Menu(X.Menu()
            .Items(
                X.MenuItem()
                    .Text("Sub menu")
                    .MenuAlign("tl-bl")
                    .Menu(
                        X.Menu().Items(
                            X.MenuItem().Text("MenuItem 1"),
                            X.MenuItem().Text("MenuItem 2")
                        )
                    )
            )    
        )
    )
    http://docs.sencha.com/extjs/4.2.1/#...-cfg-menuAlign
  5. #5
    Quote Originally Posted by Daniil View Post
    There is the MenuAlign setting.
    @(X.Button().Text("Button")
        .Menu(X.Menu()
            .Items(
                X.MenuItem()
                    .Text("Sub menu")
                    .MenuAlign("tl-bl")
                    .Menu(
                        X.Menu().Items(
                            X.MenuItem().Text("MenuItem 1"),
                            X.MenuItem().Text("MenuItem 2")
                        )
                    )
            )    
        )
    )
    http://docs.sencha.com/extjs/4.2.1/#...-cfg-menuAlign
    Thank you very much Daniil that was my need. You can close the thread.

Similar Threads

  1. Replies: 1
    Last Post: Jan 15, 2014, 4:47 AM
  2. [CLOSED] Dynamic menu items in menu panel creation problem
    By legaldiscovery in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 10, 2013, 10:29 AM
  3. [CLOSED] How to display a button menu over <object> element?
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 07, 2013, 3:48 PM
  4. [CLOSED] When button click, open the menu of button
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 22, 2012, 4:23 PM
  5. Toolbar menu click problem?
    By dbassett74 in forum 1.x Help
    Replies: 1
    Last Post: Apr 19, 2009, 2:55 AM

Posting Permissions