ComboBox
Grouping
Features
Sample
ComboBox Grouping
Use the showGroups property to add group headers to ComboBox controls.
Group header items are added if the showGroups property is set to true and the itemsSource collection has grouping enabled.
Header items are presentational only. They cannot be selected with the mouse or keyboard and are not bound to any data items.
Description
This sample shows how to show group items of the ComboBox control.
Source
GroupingController.cs
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using MvcExplorer.Models; namespace MvcExplorer.Controllers { public partial class ComboBoxController : Controller { // GET: /<controller>/ public ActionResult Grouping() { return View(_db.Orders.Take(20).ToList()); } } }
Grouping.cshtml
@model List<Order> <div> <h2> @Html.Raw(ComboBoxRes.Grouping_Text0) </h2> <p> @Html.Raw(ComboBoxRes.Grouping_Text1) </p> <p> @Html.Raw(ComboBoxRes.Grouping_Text2) </p> <p> @Html.Raw(ComboBoxRes.Grouping_Text3) </p> </div> <div> <c1-combo-box display-member-path="ShipName" selected-value-path="ShipName" selected-index="0" show-groups="true"> <c1-items-source source-collection="@Model" group-by="ShipCountry"></c1-items-source> </c1-combo-box> </div> @section Description{ @Html.Raw(ComboBoxRes.Grouping_Text4) }
Documentation