CollectionView
CollectionView
Sorting
This view shows how sorting work on CollectionView.
Features
ID
Start
End
Country
Product
Color
Amount
Amount2
Active
ID
Start
End
Country
Product
Color
Amount
Amount2
Active
0
loading...
Settings
Description
This view shows how sorting work on CollectionView.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using C1.Web.Mvc; using C1.Web.Mvc.Serialization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Primitives; using MvcExplorer.Models; namespace MvcExplorer.Controllers { public partial class CollectionViewController : Controller { private readonly ControlOptions _cVSorting = new ControlOptions { Options = new OptionDictionary { { "Sort Nulls" , new OptionItem {Values = new List< string > { "Natural" , "First" , "Last" }, CurrentValue = "Natural" }} } }; public ActionResult Sorting(IFormCollection collection) { _cVSorting.LoadPostData(collection); ViewBag.DemoOptions = _cVSorting; return View(); } public ActionResult Sorting_Bind([C1JsonRequest] CollectionViewRequest<Sale> requestData) { var extraData = requestData.ExtraRequestData .ToDictionary(kvp => kvp.Key, kvp => new StringValues(kvp.Value.ToString())); var data = new FormCollection(extraData); _optionsModel.LoadPostData(data); var model = Sale.GetData(10).ToList(); var nullObj = new Sale { }; model.Add(nullObj); return this .C1Json(CollectionViewHelper.Read(requestData, model)); } } } |
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 | @using C1.Web.Mvc.Grid @model IEnumerable< Sale > @ { ControlOptions optionsModel = ViewBag.DemoOptions; ViewBag.DemoSettings = true ; } < c1-items-source id = "CVService" read-action-url = "@Url.Action(" Sorting_Bind ")" sort-nulls = "@((CollectionViewSortNulls)Enum.Parse(typeof(CollectionViewSortNulls), optionsModel.Options[" Sort Nulls "].CurrentValue))" > </ c1-items-source > < c1-flex-grid id = "FlexGridCV" items-source-id = "CVService" auto-generate-columns = "false" class = "grid" > < c1-flex-grid-column binding = "ID" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Start" format = "MMM d yy" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "End" format = "HH:mm" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Country" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Product" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Color" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Amount" format = "c" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Amount2" format = "c" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Active" ></ c1-flex-grid-column > </ c1-flex-grid > @section Settings{ @await Html.PartialAsync( "_OptionsMenu" , optionsModel) } @section Description{ < p > @Html .Raw(CollectionViewRes.Sorting_Text0)</ p > } |