FlexGrid
編集可能なツリーグリッド
機能
サンプル
説明
FlexGridのChildItemsPathを使用してデータをツリーとして表示すると、結果のグリッドはデフォルトで読み取り専用になります。これは、ツリー内のすべての行がGroupRowであり、グループ行がデフォルトで読み取り専用であるために発生します。ツリーを編集可能にするには、OnClientLoadedRowsイベントを処理して、すべての行のIsReadOnlyプロパティをfalseに設定します。
ソース
EditableTreeGridController.cs
using Microsoft.AspNetCore.Mvc;
namespace MvcExplorer.Controllers
{
public partial class FlexGridController : Controller
{
public ActionResult EditableTreeGrid()
{
return View();
}
}
}
EditableTreeGrid.cshtml
@model IEnumerable<ITreeItem>
@{
var list = Folder.Create(Startup.Environment.ContentRootPath).Children;
}
@section Styles{
<style>
.custom-flex-grid {
height: 400px;
background-color: white;
box-shadow: 4px 4px 10px 0px rgba(50, 50, 50, 0.75);
margin-bottom: 12px;
}
.custom-flex-grid .wj-cell {
background-color: #fff;
border: none;
font-size: 10pt;
}
.custom-flex-grid .wj-state-selected {
background: #000;
color: #fff;
}
.custom-flex-grid .wj-state-multi-selected {
background: #222;
color: #fff;
}
</style>
}
@section Scripts{
<script>
c1.documentReady(function () {
wijmo.Control.getControl("#grid").rows.defaultSize = 25;
});
function setEditableRows(s, e) {
s.rows.forEach(function (row) {
row.isReadOnly = false;
});
}
</script>
}
<label>@Html.Raw(FlexGridRes.TreeGrid_Text0)</label>
<c1-flex-grid id="grid" class="custom-flex-grid" width="500px"
child-items-path="Children" auto-generate-columns="false"
allow-resizing="None" headers-visibility="Column" selection-mode="Row" loaded-rows="setEditableRows">
<c1-items-source source-collection="list"></c1-items-source>
<c1-flex-grid-column binding="Header" width="*"></c1-flex-grid-column>
<c1-flex-grid-column binding="Size" width="80" align="center"></c1-flex-grid-column>
</c1-flex-grid>
@section Description {
@Html.Raw(FlexGridRes.TreeGrid_Editable_Description)
}
マニュアル