Your search did not match any results.


Populate Menu with Data and Configure the Access to It

You can display Menu items from the items array or a dataSource. This demo contains an example of a data structure. If you use a dataSource, specify the displayExpr property.

To access the clicked item, use the onItemClick event handler function.

Configure the Menu

Use the orientation property to specify whether the Menu has horizontal or vertical orientation. Use the animation property to specify the type, delay, duration, and other options of show and hide menu actions.

Configure the Submenus

Clicking or a hovering a Menu item opens a drop-down menu that can contain several submenus. To specify the drop-down menu mode ("onClick" or "onHover"), use the showSubmenuMode property. If you need only to specify the first level of drop-down menus, use the showFirstSubmenuMode property.

If you want to hide the submenu when the mouse pointer leaves it, set the hideSubmenuOnMouseLeave property to true.

Customize Item Appearance

You can define specific fields in the item data objects to change the appearance of an item. For example, use the icon property to supply items with icons. Define an itemTemplate to customize item appearance.

Backend API
<div class="form"> <div> <div class="label">Catalog:</div> @(Html.DevExtreme().Menu() .ID("menu") .DataSource(d => d.Mvc().LoadAction("GetProducts")) .HideSubmenuOnMouseLeave(false) .OnItemClick("menuItem_click") ) <div id="product-details" class="hidden"> <img src="" /> <div class="name"></div> <div class="price"></div> </div> </div> <div class="options"> <div class="caption">Options</div> <div class="option"> <div>Show First Submenu Mode</div> @(Html.DevExtreme().SelectBox() .DataSource(new JS("showSubmenuModes")) .InputAttr("aria-label", "Submenu Mode") .Value(new JS("showSubmenuModes[1]")) .DisplayExpr("name") .OnValueChanged("firstSubMenuMode_changed") ) </div> <div class="option"> <div>Orientation</div> @(Html.DevExtreme().SelectBox() .DataSource(new[] { "horizontal", "vertical" }) .InputAttr("aria-label", "Orientation") .Value("horizontal") .OnValueChanged("menuOrientation_changed") ) </div> <div class="option"> @(Html.DevExtreme().CheckBox() .Value(false) .Text("Hide Submenu on Mouse Leave") .OnValueChanged("checkBoxValue_changed") ) </div> </div> </div> <script> var showSubmenuModes = [{ name: "onHover", delay: { show: 0, hide: 500 } }, { name: "onClick", delay: { show: 0, hide: 300 } }]; function getMenuInstance() { return $("#menu").dxMenu("instance"); } function menuItem_click(data) { var item = data.itemData; if (item.price) { $("#product-details").removeClass("hidden"); $("#product-details > img").attr("src", item.icon); $("#product-details > .price").text("$" + item.price); $("#product-details > .name").text(item.text); } } function firstSubMenuMode_changed(data) { getMenuInstance().option("showFirstSubmenuMode", data.value); } function menuOrientation_changed(data) { getMenuInstance().option("orientation", data.value); } function checkBoxValue_changed(data) { getMenuInstance().option("hideSubmenuOnMouseLeave", data.value); } </script>
.form { margin-left: 3px; } .label { font-size: 22px; padding-bottom: 24px; } #product-details { width: 400px; height: 400px; margin: 20px auto 0; } #product-details > img { height: 300px; width: 400px; } #product-details > .name { text-align: center; font-size: 20px; } #product-details > .price { text-align: center; font-size: 24px; } .dark #product-details > div { color: #f0f0f0; } .options { padding: 20px; position: absolute; bottom: 0; right: 0; width: 260px; top: 0; background-color: rgba(191, 191, 191, 0.15); } .option { margin-top: 10px; } .caption { font-size: 18px; font-weight: 500; } .hidden { visibility: hidden; }