CollectionView
CollectionView
Overview
This view shows basic features of CollectionView ASP.NET MVC.
Features
Sample
Settings
Description
This view shows basic features of CollectionView ASP.NET MVC.
The refreshOnEdit property determines whether the CollectionView should automatically refresh its results (by applying the sort, filter, and grouping operations) after items are edited. This property is set to true by default, which ensures the collection is always sorted, filtered, and grouped correctly after any edit operations.
Source
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> }
Documentation