CollectionView
CollectionView
Sorting
This view shows how sorting work on CollectionView.
Features
ID
Start
End
Country
Product
Color
Amount
Amount2
Active
1
Jan 25 25
00:00
German
Gadget
Green
$581.61
$1,030.17
2
Feb 25 25
01:30
Italy
Gadget
Green
($4,673.75)
$3,499.71
3
Mar 25 25
02:00
China
Gadget
Black
($2,265.49)
$4,535.49
4
Apr 25 25
03:30
France
Widget
Green
$3,964.40
$432.90
5
May 25 25
04:00
UK
Widget
Red
($1,744.99)
$3,355.18
6
Jun 25 25
05:30
France
Gadget
Red
$4,276.37
$1,106.71
7
Jul 25 25
06:00
US
Widget
Green
($4,376.92)
$1,408.24
8
Aug 25 25
07:30
Japan
Gadget
Black
$1,996.52
$3,077.04
9
Sep 25 25
08:00
Korea
Widget
Red
($3,442.35)
$4,068.26
10
Oct 25 25
09:30
US
Widget
Green
($2,973.96)
$4,568.15
0
Apr 9 25
09:56
$0.00
$0.00
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 > } |