ComboBox
グループ化
機能
サンプル
ComboBox Grouping
showGroups プロパティを使用して、 ComboBox コントロールにグループヘッダーを追加します。
showGroups プロパティがtrueに設定されていて、 itemsSource コレクションでグループ化が有効になっている場合、グループヘッダー項目が追加されます。
ヘッダー項目は表示のみです。 マウスやキーボードで選択することはできず、どのデータ項目にもバインドされていません。
説明
このサンプルは、ComboBoxコントロールのグループ項目を表示する方法を示します。
ソース
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)
}
マニュアル