CollectionView
CollectionView
Sorting
This view shows how sorting work on CollectionView.
Features
ID
Start
End
Country
Product
Color
Amount
Amount2
Discount
Active
ID
Start
End
Country
Product
Color
Amount
Amount2
Discount
Active
1
Jan 25 25
00:00
German
Gadget
Green
$581.61
$1,030.17
14%
2
Feb 25 25
01:30
Italy
Gadget
Green
($4,673.75)
$3,499.71
13%
3
Mar 25 25
02:00
China
Gadget
Black
($2,265.49)
$4,535.49
20%
4
Apr 25 25
03:30
France
Widget
Green
$3,964.40
$432.90
21%
5
May 25 25
04:00
UK
Widget
Red
($1,744.99)
$3,355.18
12%
6
Jun 25 25
05:30
France
Gadget
Red
$4,276.37
$1,106.71
23%
7
Jul 25 25
06:00
US
Widget
Green
($4,376.92)
$1,408.24
18%
8
Aug 25 25
07:30
Japan
Gadget
Black
$1,996.52
$3,077.04
21%
9
Sep 25 25
08:00
Korea
Widget
Red
($3,442.35)
$4,068.26
16%
10
Oct 25 25
09:30
US
Widget
Green
($2,973.96)
$4,568.15
1%
0
Jul 27 25
21:53
$0.00
$0.00
0%
0
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 | 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 _cVSorting = new ControlOptions { Options = new OptionDictionary { { "SortNulls" , new OptionItem {Values = new List< string > { "Natural" , "First" , "Last" }, CurrentValue = "Natural" }} } }; public ActionResult Sorting(FormCollection data) { _cVSorting.LoadPostData(data); ViewBag.DemoOptions = _cVSorting; var model = Sale.GetData(10).ToList(); var nullObj = new Sale { }; model.Add(nullObj); return View(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 31 32 33 34 35 36 37 38 39 40 41 42 | @using C1.Web.Mvc.Grid @model IEnumerable< Sale > @ { ControlOptions optionsModel = ViewBag.DemoOptions; ViewBag.DemoSettings = true ; } @ (Html.C1().CollectionViewService() .Id( "CVService" ) .Bind(Model) .SortNulls((CollectionViewSortNulls)Enum.Parse( typeof (CollectionViewSortNulls), optionsModel.Options[ "SortNulls" ].CurrentValue)) ) @ (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" )); }) .CssClass( "grid" ) .Height(500) ) @section Settings{ @Html .Partial( "_OptionsMenu" , optionsModel) } @section Description{ < p > @Html .Raw(Resources.CollectionView.Sorting_Text0)</ p > } |