mvc razor bind contextmenu in buttons?

  1. #1

    mvc razor bind contextmenu in buttons?

      X.Menu().ID("mn1").Items(
        X.MenuItem().Text("menu1")
    , X.MenuItem().Text("menu2"))
    
      X.Button().Text("Exp").ID("btnAdd").ContextMenuID("mn1").tag(new { dataValue="test1" })
      X.Button().Text("Exp2").ID("btnEdit").ContextMenuID("mn1").tag(new { dataValue="test1" })
    I want to bind contextmenu in buttons,
    on 'menu1' click ,I want get the button tag value, what should I do.

    thanks .
  2. #2
    Hello!

    Try the following:

    @(X.Menu()
        .ID("MyMenu")
        .CustomConfig(c => {
            c.Add(new ConfigItem("parentButton", "MyButton", ParameterMode.Value));
        })
        .Items(
            X.MenuItem()
                .Text("My Menu Item")
                .Listeners(l => l.Click.Handler = "Ext.Msg.alert('Button tag value', Ext.getCmp(item.parentMenu.parentButton).tag.dataValue);" )
        )
    )
        
    @(X.Button()
        .ID("MyButton")
        .Text("MyButton")
        .ContextMenuID("MyMenu")
        .CustomConfig(c => {
                c.Add(new ConfigItem("tag", JSON.Serialize(new { dataValue="test1" }), ParameterMode.Raw));
            })
    )

Similar Threads

  1. Replies: 4
    Last Post: Aug 07, 2012, 10:02 AM
  2. Replies: 1
    Last Post: Apr 09, 2012, 1:07 PM
  3. [CLOSED] [1.0] Radio buttons that appear as buttons
    By MP in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 24, 2010, 6:28 PM
  4. ContextMenu
    By Maia in forum 1.x Help
    Replies: 2
    Last Post: Dec 08, 2009, 4:12 PM
  5. Image buttons / Custom built buttons
    By conman in forum 1.x Help
    Replies: 2
    Last Post: Jul 15, 2008, 11:01 AM

Posting Permissions