ComboBox
Grouping
This sample shows how to show group items of the ComboBox control.
Features
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | using MvcExplorer.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace MvcExplorer.Controllers { public partial class ComboBoxController : Controller { // GET: Grouping public ActionResult Grouping() { var nwind = new C1NWindEntities(); return View(nwind.Suppliers.Take(20)); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | @model IEnumerable< Supplier > @ (Html.C1().CollectionViewService< Supplier >().Bind(Model).Id( "collectionViewService" ).GroupBy( "Country" )) < div > < h2 > @Html .Raw(Resources.ComboBox.Grouping_Text0) </ h2 > < p > @Html .Raw(Resources.ComboBox.Grouping_Text1) </ p > < p > @Html .Raw(Resources.ComboBox.Grouping_Text2) </ p > < p > @Html .Raw(Resources.ComboBox.Grouping_Text3) </ p > </ div > < div > @ (Html.C1().ComboBox().Id( "theComboBox" ) .ShowGroups( true ) .DisplayMemberPath( "CompanyName" ) .ItemsSourceId( "collectionViewService" )) </ div > @section Description{ @Html .Raw(Resources.ComboBox.Grouping_Text4) } |