If you have technical questions, please create a support ticket in the DevExpress Support Center.
<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>
xxxxxxxxxx
using DevExtreme.AspNet.Data;
using DevExtreme.AspNet.Mvc;
using DevExtreme.NETCore.Demos.Models.SampleData;
using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
namespace DevExtreme.NETCore.Demos.Controllers {
public class MenuController : Controller {
public ActionResult Overview() {
return View();
}
public ActionResult Scrolling() {
return View();
}
[HttpGet]
public object GetProducts(DataSourceLoadOptions loadOptions) {
return DataSourceLoader.Load(MenuData.Products, loadOptions);
}
[HttpGet]
public ActionResult GetScrollingProducts(DataSourceLoadOptions loadOptions) {
return Content(JsonSerializer.Serialize(DataSourceLoader.Load(MenuScrollingData.Products, loadOptions)), "application/json");
}
}
}
xxxxxxxxxx
using System;
using System.Collections.Generic;
using System.Linq;
namespace DevExtreme.NETCore.Demos.Models.SampleData {
public static class MenuData {
public static readonly IEnumerable<MenuItem> Products = new[] {
new MenuItem {
text = "Video Players",
items = new[] {
new MenuItem {
text = "HD Video Player",
price = 220,
icon = "../../images/ProductsLarge/1.png"
},
new MenuItem {
text = "SuperHD Video Player",
price = 270,
icon = "../../images/ProductsLarge/2.png"
}
}
},
new MenuItem {
text = "Televisions",
items = new[] {
new MenuItem {
text = "SuperLCD 42",
price = 1200,
icon = "../../images/ProductsLarge/7.png"
},
new MenuItem {
text = "SuperLED 42",
price = 1450,
icon = "../../images/ProductsLarge/5.png"
},
new MenuItem {
text = "SuperLED 50",
price = 1600,
icon = "../../images/ProductsLarge/4.png"
},
new MenuItem {
text = "SuperLCD 55 (Not available)",
price = 1350,
icon = "../../images/ProductsLarge/6.png",
disabled = true
},
new MenuItem {
text = "SuperLCD 70",
price = 4000,
icon = "../../images/ProductsLarge/9.png"
}
}
},
new MenuItem {
text = "Monitors",
items = new[] {
new MenuItem {
text = "19\"",
items = new[] {
new MenuItem {
text = "DesktopLCD 19",
price = 160,
icon = "../../images/ProductsLarge/10.png"
}
}
},
new MenuItem {
text = "21\"",
items = new[] {
new MenuItem {
text = "DesktopLCD 21",
price = 170,
icon = "../../images/ProductsLarge/12.png"
},
new MenuItem {
text = "DesktopLED 21",
price = 175,
icon = "../../images/ProductsLarge/13.png"
}
}
}
}
},
new MenuItem {
text = "Projectors",
items = new[] {
new MenuItem {
text = "Projector Plus",
price = 550,
icon = "../../images/ProductsLarge/14.png"
},
new MenuItem {
text = "Projector PlusHD",
price = 750,
icon = "../../images/ProductsLarge/15.png"
}
}
}
};
}
}
xxxxxxxxxx
using System;
using System.Collections.Generic;
using System.Linq;
namespace DevExtreme.NETCore.Demos.Models {
public class MenuItem {
public string text { get; set; }
public bool disabled { get; set; }
public string icon { get; set; }
public int price { get; set; }
public IEnumerable<MenuItem> items { get; set; }
}
}
xxxxxxxxxx
.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;
}
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.