Skip to main content

MenuSettingsBase.AllowSelectItem Property

Gets or sets a value specifying whether items can be selected within the menu.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v24.2.dll

Declaration

public bool AllowSelectItem { get; set; }

Property Value

Type Description
Boolean

true if items can be selected; otherwise false.

Remarks

Set the AllowSelectItem property to true to enable menu item selection. If it is enabled, clicking on an item selects it. Otherwise, items cannot be selected. Note that only one item can be selected within a menu at the same time.

Example

In the code sample below, the Menu control is bound to a Site Map data source. An item’s NavigateUrl and Text property values are automatically retrieved from the url and title Site Map node attributes respectively (to learn more, see the Automatic Data Binding topic). The ItemDataBound event is handled for two purposes.

  1. To add an image sprite CSS class to items that have the corresponding attribute (“SpriteImage”) within the data source.
  2. To bold a score and add it to text of items that have the corresponding attribute (“result”) within the data source.

The image below shows the result.

ASPxMenu_DataBindingEvents

You can see the complete sample in the Menu - Data Binding to SiteMap on-line demo.

@Html.DevExpress().Menu(settings => {
    settings.Name = "mDataBinding";
    settings.AllowSelectItem = true;
    settings.EncodeHtml = false;
    settings.Orientation = Orientation.Vertical;
    settings.Styles.SubMenuItem.ImageSpacing = 8;
    settings.Width = 100;

    settings.ItemDataBound = (sender, e) => {
        var node = e.Item.DataItem as SiteMapNode;
        if(node != null) {
            if(!string.IsNullOrEmpty(node["SpriteImage"]))
                e.Item.Image.SpriteProperties.CssClass = node["SpriteImage"];
            e.Item.Text = "<b>" + node["result"] + "</b> " + e.Item.Text;
        }
    };
}).BindToSiteMap("~/App_Data/WorldCup2010.sitemap", false).GetHtml()
See Also