CollectionView
CollectionView
概要
このビューには、CollectionView ASP.NET MVCの基本機能が表示されます。
機能
サンプル
設定
説明
このビューには、CollectionView ASP.NET MVCの基本機能が表示されます。
RefreshOnEdit プロパティは、アイテムの編集後にCollectionViewが(並べ替え、フィルター、およびグループ化操作を適用して)結果を自動的に更新するかどうかを決定します。 このプロパティはデフォルトで true に設定されています。これにより、編集操作後にコレクションが常に正しくソート、フィルター、およびグループ化されます。
ソース
IndexController.cs
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 CollectionViewController : Controller
{
private readonly ControlOptions _optionsModel = new ControlOptions
{
Options = new OptionDictionary
{
{"Refresh On Edit", new OptionItem {Values = new List<string> {"True", "False"}, CurrentValue = "True"}}
}
};
public ActionResult Index(FormCollection data)
{
_optionsModel.LoadPostData(data);
ViewBag.DemoOptions = _optionsModel;
var model = Sale.GetData(500);
return View(model);
}
}
}
Index.cshtml
@using C1.Web.Mvc.Grid
@model IEnumerable<Sale>
@{
ControlOptions optionsModel = ViewBag.DemoOptions;
ViewBag.DemoSettings = true;
}
@(Html.C1().CollectionViewService()
.Id("CVService")
.Bind(Model)
.RefreshOnEdit(Convert.ToBoolean(optionsModel.Options["Refresh On Edit"].CurrentValue))
.DisableServerRead(true)
)
@(Html.C1().FlexGrid<Sale>()
.Id("FlexGridCV")
.ItemsSourceId("CVService")
.AutoGenerateColumns(false)
.Columns(bl =>
{
bl.Add(cb => cb.Binding("ID"));
bl.Add(cb => cb.Binding("Start").Format("MMM d yy"));
bl.Add(cb => cb.Binding("End").Format("HH:mm"));
bl.Add(cb => cb.Binding("Country"));
bl.Add(cb => cb.Binding("Product"));
bl.Add(cb => cb.Binding("Color"));
bl.Add(cb => cb.Binding("Amount").Format("c"));
bl.Add(cb => cb.Binding("Amount2").Format("c"));
bl.Add(cb => cb.Binding("Discount").Format("p0"));
bl.Add(cb => cb.Binding("Active"));
})
.SortingType(AllowSorting.SingleColumn)
.CssClass("grid")
.Height(500)
)
@section Summary{
<p>@Html.Raw(Resources.CollectionView.Index_Text0)</p>
}
@section Settings{
@Html.Partial("_OptionsMenu", optionsModel)
}
@section Description{
<p>@Html.Raw(Resources.CollectionView.Index_Text0)</p>
<p>@Html.Raw(Resources.CollectionView.Index_Text1)</p>
}
マニュアル