ListBox
Grouping
This sample shows how to show group items of the ListBox control.
Features
ListBox Grouping
Use the showGroups property to add group headers to ListBox 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.
UK
Exotic Liquids
Specialty Biscuits, Ltd.
USA
New Orleans Cajun Delights
Grandma Kelly's Homestead
Bigfoot Breweries
New England Seafood Cannery
Japan
Tokyo Traders
Mayumi's
Spain
Cooperativa de Quesos 'Las Cabras'
Australia
Pavlova, Ltd.
Sweden
PB Knäckebröd AB
Brazil
Refrescos Americanas LTDA
Germany
Heli Süßwaren GmbH & Co. KG
Plutzer Lebensmittelgroßmärkte AG
Nord-Ost-Fisch Handelsgesellschaft mbH
Italy
Formaggi Fortini s.r.l.
Norway
Norske Meierier
Sweden
Svensk Sjöföda AB
France
Aux joyeux ecclésiastiques
Singapore
Leka Trading
Description
This sample shows how to show group items of the ListBox control.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 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 ListBoxController : 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.ListBox.Grouping_Text0) </ h2 > < p > @Html .Raw(Resources.ListBox.Grouping_Text1) </ p > < p > @Html .Raw(Resources.ListBox.Grouping_Text2) </ p > < p > @Html .Raw(Resources.ListBox.Grouping_Text3) </ p > </ div > < div > @ (Html.C1().ListBox() .ShowGroups( true ) .DisplayMemberPath( "CompanyName" ) .ItemsSourceId( "collectionViewService" ) .Width(250).Height(200)) </ div > @section Description{ @Html .Raw(Resources.ListBox.Grouping_Text4) } |