Unbound Mode

  • 2 minutes to read

In Unbound Mode, the PopupMenu is not bound to any data source and can be populated manually. To create nodes, use the MVCxMenuItemCollection.Add methods.

View code (ASPX):

<%
    Html.DevExpress().PopupMenu(
    settings => {
        settings.Items.Add(item => {
            item.Text = "Sort By Column";
            item.Name = "Column";
            item.Items.Add(subitem => {
                subitem.Text = "Country Name";
                subitem.Name = "Country Name";
            });
            item.Items.Add(subitem => {
                subitem.Text = "Area";
                subitem.Name = "Area";
            });
            item.Items.Add(subitem => {
                subitem.Text = "Population";
                subitem.Name = "Population";
            });
        });
        settings.Items.Add(item => {
            item.Text = "Sort Order";
            item.Name = "Order";
            item.Items.Add(subitem => {
               subitem.Text = "Ascending Sort";
               subitem.Name = "Ascending";
            });
            item.Items.Add(subitem => {
               subitem.Text = "Descending Sort";
               subitem.Name = "Descending";
            });
        });
        settings.Items.Add(item => {
            item.Text = "Unsort";
            item.Name = "Unsort";
        });
        settings.ClientSideEvents.Init = "InitPopupMenuHandler";
        settings.ClientSideEvents.ItemClick = "OnPopupMenuItemClick";
    })
    .Render();
%>

View code (Razor):

@Html.DevExpress().PopupMenu(settings => {
     settings.Name = "PopupMenu";
     settings.PopupElementID = "grid";
     settings.Items.Add(item => {
          item.Text = "Sort By Column";
          item.Name = "Column";
          item.Items.Add(subitem => {
               subitem.Text = "Country Name";
               subitem.Name = "Country Name";
          });
          item.Items.Add(subitem => {
               subitem.Text = "Area";
               subitem.Name = "Area";
          });
          item.Items.Add(subitem => {
               subitem.Text = "Population";
               subitem.Name = "Population";
          });
     });
     settings.Items.Add(item => {
          item.Text = "Sort Order";
          item.Name = "Order";
          item.Items.Add(subitem => {
               subitem.Text = "Ascending Sort";
               subitem.Name = "Ascending";
          });
          item.Items.Add(subitem => {
               subitem.Text = "Descending Sort";
               subitem.Name = "Descending";
                });
     });
     settings.Items.Add(item => {
          item.Text = "Unsort";
          item.Name = "Unsort";
     });
     settings.ClientSideEvents.Init = "InitPopupMenuHandler";
     settings.ClientSideEvents.ItemClick = "OnPopupMenuItemClick";
}).GetHtml()

The image below illustrates the result.

PopupMenu_UnboundMode