ASPxMenuBase.SelectParentItem Property
Gets or sets whether a root menu item is displayed selected when selecting any of its subitems.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v19.2.dll
Declaration
Property Value
Type | Default | Description |
---|---|---|
Boolean | **false** | true to visually highlight a root menu item that contains a selected subitem; otherwise, false. |
Remarks
Use the SelectParentItem property to control whether the root menu item, one of whose subitems is selected (see the MenuItem.Selected property), should be displayed using a selected style.
Note
The SelectParentItem property’s functionality is in effect only when a round-trip to the server occurs after clicking a menu item (that is, when the menu’s ASPxMenuBase.AutoPostBack property is set to true or the MenuItem.NavigateUrl property of the clicked menu item is defined). So, the parent root item doesn’t change its selected state if its child menu item’s selected state is changed on the client side (by an end-user or programmatically).
Example
The complete sample project is available in the DevExpress Code Central database at E1111.
...
<dxm:ASPxMenu ID="ASPxMenu1" runat="server" BorderBetweenItemAndSubMenu="HideAll"
OnItemClick="ASPxMenu1_ItemClick" SelectParentItem="True" ShowPopOutImages="True">
<Items>
<dxm:MenuItem Text="Root 1">
<Items>
<dxm:MenuItem Text="Sub Item">
<Items>
<dxm:MenuItem Text="Item 1-1">
</dxm:MenuItem>
<dxm:MenuItem Text="Item 1-2">
</dxm:MenuItem>
</Items>
</dxm:MenuItem>
<dxm:MenuItem Text="Item 1-3">
</dxm:MenuItem>
</Items>
</dxm:MenuItem>
<dxm:MenuItem Text="Root 2">
<Items>
<dxm:MenuItem Text="Item 2-1">
</dxm:MenuItem>
<dxm:MenuItem Text="Item 2-2">
</dxm:MenuItem>
<dxm:MenuItem Text="Item 2-3">
</dxm:MenuItem>
</Items>
</dxm:MenuItem>
</Items>
<ClientSideEvents ItemClick="function(s, e) {
e.processOnServer = e.item.GetItemCount() == 0; // Prevent generating a postback for parent menu items
}" />
</dxm:ASPxMenu>
...