Gets or sets a value specifying whether items can be selected within the menu.
Namespace: DevExpress.Web.Mvc
Assembly: DevExpress.Web.Mvc5.v19.2.dll
Type | Description |
---|---|
Boolean | true if items can be selected; otherwise false. |
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.
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.
The image below shows the result.
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()