FlexGrid
Data Map
Features
Data Map
Data maps provide the grid with automatic look up capabilities. For example, you may want to display a customer name instead of his ID, or a color name instead of its RGB value.
Columns with an associated data map can be sorted by the mapped display value instead of the binding value.
Columns with an associated data map can be showed as AutoComplete, DropDownList or RadioButtons. You can choose these by setting DataMapEditor property.
Start
End
Country
Product
Color
Amount
Amount2
Discount
Active
Rank
Jan 25 25
00:00
German
Gadget
Charcoal
$581.61
($2,939.67)
14%
true
Feb 25 25
01:01
Canada
Gadget
Black Cat
$4,919.02
($4,673.75)
17%
false
Start
End
Country
Product
Color
Amount
Amount2
Discount
Active
Rank
0
loading...
Multi-column Data Map
The FlexGrid columns have a DropDownCssClass property that can be used to style the drop-downs used to edit values in data-mapped columns.
To see the multi-column editor in action, click one of the drop-down buttons in the "Color" column, or select a cell in that column and press F4:
Start
End
Country
Product
Color
Amount
Amount2
Discount
Active
Jan 25 25
00:00
German
Gadget
Charcoal
$581.61
($2,939.67)
14%
Feb 25 25
01:01
Canada
Gadget
Black Cat
$4,919.02
($4,673.75)
17%
Mar 25 25
02:02
Japan
Gadget
Brown
$2,159.73
($3,810.42)
7%
Apr 25 25
03:03
German
Gadget
Gunmetal
$1,248.66
($2,815.93)
22%
May 25 25
04:04
German
Gadget
Green
$4,051.76
($3,108.76)
12%
Jun 25 25
05:05
Canada
Gadget
LightBlue
($3,131.28)
($4,314.81)
16%
Jul 25 25
06:06
China
Widget
Gunmetal
$698.62
($2,745.97)
15%
Aug 25 25
07:07
US
Widget
Brown
$3,464.15
$1,131.58
3%
Sep 25 25
08:08
Korea
Gadget
White
($2,363.16)
$3,425.60
14%
Oct 25 25
09:09
US
Widget
Brown
($2,836.94)
($4,283.10)
6%
Nov 25 25
10:10
France
Widget
Venom Green
$877.93
$2,722.02
8%
Dec 25 25
11:11
Korea
Widget
Gunmetal
($3,788.14)
($3,050.89)
12%
Jan 25 25
12:12
German
Gadget
Night
($2,446.92)
($2,351.67)
12%
Feb 25 25
13:13
German
Widget
DarkBlue
($4,374.97)
($3,899.38)
18%
Mar 25 25
14:14
Japan
Gadget
Venom Green
$1,089.32
($4,102.95)
16%
Apr 25 25
15:15
China
Gadget
Cyan
$1,341.85
$532.34
8%
May 25 25
16:16
US
Widget
Green
$3,596.33
$623.80
18%
Jun 25 25
17:17
China
Widget
Black Cat
$3,232.11
$305.20
24%
Jul 25 25
18:18
France
Gadget
Columbia Blue
($2,008.99)
$1,805.09
9%
Aug 25 25
19:19
France
Gadget
Lime
$2,568.01
$2,889.37
3%
Sep 25 25
20:20
UK
Widget
White
($3,476.95)
$4,852.50
1%
Oct 25 25
21:21
UK
Widget
Gray
$2,290.56
$3,295.03
6%
Nov 25 25
22:22
Japan
Gadget
Maroon
($4,146.76)
$853.06
1%
Dec 25 25
23:23
Canada
Gadget
Gray
$4,917.55
($4,479.39)
14%
Jan 25 25
00:24
Korea
Gadget
White
$3,824.28
$2,007.51
8%
Feb 25 25
01:25
Japan
Gadget
Olive
($4,257.83)
($1,652.26)
23%
Mar 25 25
02:26
Italy
Gadget
LightBlue
$1,095.08
$1,413.34
20%
Apr 25 25
03:27
German
Gadget
Columbia Blue
$1,853.66
$4,924.12
18%
May 25 25
04:28
Italy
Widget
Magenta
$3,708.86
($2,697.08)
3%
Jun 25 25
05:29
Canada
Gadget
Teal
($3,447.73)
$3,738.87
10%
Jul 25 25
06:30
German
Gadget
Olive
($165.64)
($4,919.21)
4%
Aug 25 25
07:31
China
Widget
Lime
$160.62
$1,299.66
8%
Sep 25 25
08:32
Korea
Widget
Orange
($2,575.30)
($1,036.23)
17%
Oct 25 25
09:33
Italy
Widget
Midnight
$3,288.12
($2,392.41)
19%
Nov 25 25
10:34
Korea
Gadget
Gray
($4,563.28)
$1,361.51
2%
Dec 25 25
11:35
Canada
Widget
Olive
($4,839.71)
($1,835.02)
19%
Jan 25 25
12:36
US
Gadget
Midnight
$544.13
($4,548.24)
10%
Feb 25 25
13:37
Canada
Widget
Midnight
$538.45
$1,848.22
4%
Mar 25 25
14:38
Japan
Gadget
Brown
$1,493.10
$391.20
19%
Apr 25 25
15:39
US
Widget
Green
($2,838.54)
$4,241.04
14%
May 25 25
16:40
UK
Gadget
DarkBlue
($3,175.21)
($2,650.41)
18%
Jun 25 25
17:41
France
Widget
Red
$22.88
($2,410.67)
17%
Jul 25 25
18:42
Korea
Widget
Cyan
($4,129.88)
($3,660.62)
17%
Aug 25 25
19:43
Korea
Gadget
Oil
$2,170.82
($3,562.14)
14%
Sep 25 25
20:44
Korea
Gadget
Midnight
($3,000.98)
($238.75)
9%
Oct 25 25
21:45
US
Gadget
Night
$3,374.49
($4,629.37)
23%
Nov 25 25
22:46
Canada
Widget
Charcoal
($2,103.52)
($4,860.82)
23%
Dec 25 25
23:47
German
Widget
Orange
($2,077.64)
($4,678.39)
6%
Jan 25 25
00:48
France
Gadget
Venom Green
($748.11)
$1,463.78
14%
Feb 25 25
01:49
German
Widget
Orange
$678.23
$95.72
3%
Mar 25 25
02:50
Italy
Gadget
Olive
$4,420.76
($4,654.08)
1%
Apr 25 25
03:51
China
Widget
Orange
($4,161.96)
$272.81
7%
May 25 25
04:52
China
Gadget
Midnight
($4,266.09)
($4,920.97)
6%
Jun 25 25
05:53
Korea
Gadget
Oil
($3,422.65)
$2,304.34
22%
Jul 25 25
06:54
China
Gadget
Gunmetal
($185.37)
($280.05)
12%
Aug 25 25
07:55
US
Widget
Charcoal
($4,675.00)
$4,759.93
9%
Sep 25 25
08:56
Canada
Gadget
Red
($1,746.26)
($780.98)
19%
Oct 25 25
09:57
German
Widget
Teal
($3,518.88)
($2,779.71)
5%
Nov 25 25
10:58
Canada
Widget
Gunmetal
($228.15)
$3,505.17
20%
Dec 25 25
11:59
Italy
Widget
Orange
($839.21)
$1,002.81
21%
Jan 25 25
12:00
US
Widget
White
$2,042.44
$1,010.09
2%
Feb 25 25
13:01
US
Gadget
Olive
$4,568.40
$2,813.06
21%
Mar 25 25
14:02
Korea
Widget
Magenta
$595.84
($369.24)
4%
Apr 25 25
15:03
Canada
Gadget
Night
($2,520.97)
$31.56
9%
May 25 25
16:04
Korea
Gadget
Lime
$3,017.71
$2,732.26
12%
Jun 25 25
17:05
Korea
Widget
Silver
($3,412.10)
$3,802.04
22%
Jul 25 25
18:06
Korea
Gadget
Maroon
($3,256.14)
($3,342.69)
0%
Aug 25 25
19:07
China
Gadget
Magenta
$4,334.98
($1,274.35)
17%
Sep 25 25
20:08
China
Widget
Black
($989.05)
($4,651.12)
9%
Oct 25 25
21:09
US
Widget
Silver
$2,673.11
($1,656.47)
1%
Nov 25 25
22:10
Japan
Gadget
Columbia Blue
$4,676.20
($2,435.42)
4%
Dec 25 25
23:11
German
Widget
Cyan
($4,427.85)
($952.53)
13%
Jan 25 25
00:12
Japan
Gadget
Orange
($4,916.10)
($507.49)
19%
Feb 25 25
01:13
China
Widget
Purple
($1,940.69)
($2,854.91)
0%
Mar 25 25
02:14
German
Widget
Maroon
($862.78)
$4,355.25
10%
Apr 25 25
03:15
Canada
Gadget
Purple
$2,015.45
($1,489.64)
25%
May 25 25
04:16
Japan
Gadget
Purple
$4,585.00
($2,963.00)
16%
Jun 25 25
05:17
US
Widget
Brown
$1,986.58
$606.61
6%
Jul 25 25
06:18
US
Widget
Cyan
($3,469.64)
($1,856.72)
25%
Aug 25 25
07:19
German
Gadget
Brown
$2,342.70
($3,639.94)
5%
Sep 25 25
08:20
UK
Gadget
Gunmetal
$4,479.22
($842.31)
21%
Oct 25 25
09:21
US
Gadget
Iridium
$2,869.30
$3,725.41
12%
Nov 25 25
10:22
US
Gadget
Black
($2,190.02)
($2,736.44)
18%
Dec 25 25
11:23
Italy
Widget
White
$322.50
($3,277.44)
23%
Jan 25 25
12:24
France
Widget
Midnight
($1,479.40)
$3,151.24
12%
Feb 25 25
13:25
Italy
Widget
DarkBlue
$3,689.48
($1,072.41)
10%
Mar 25 25
14:26
Canada
Widget
Venom Green
($1,241.87)
$2,966.15
24%
Apr 25 25
15:27
Japan
Gadget
Yellow
$4,009.94
($3,149.85)
11%
May 25 25
16:28
Japan
Gadget
Gray
$2,323.39
$444.47
16%
Jun 25 25
17:29
Italy
Gadget
Venom Green
($1,227.88)
$1,787.36
12%
Jul 25 25
18:30
German
Widget
Magenta
($456.57)
$2,388.73
20%
Aug 25 25
19:31
Italy
Widget
White
($992.57)
($1,438.44)
25%
Sep 25 25
20:32
Canada
Gadget
DarkBlue
($4,707.05)
($1,935.98)
19%
Oct 25 25
21:33
US
Widget
Oil
$2,301.03
$1,134.37
24%
Nov 25 25
22:34
German
Gadget
Venom Green
($1,062.14)
$2,694.52
5%
Dec 25 25
23:35
France
Widget
White
($587.13)
$974.87
4%
Jan 25 25
00:36
US
Gadget
Magenta
$2,518.17
$1,421.02
19%
Feb 25 25
01:37
Japan
Widget
Gunmetal
$4,900.51
$3,229.92
16%
Mar 25 25
02:38
Japan
Gadget
Lime
$2,920.44
$4,808.53
0%
Apr 25 25
03:39
France
Widget
Charcoal
$568.63
$329.90
13%
Start
End
Country
Product
Color
Amount
Amount2
Discount
Active
0
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | using System; using System.Collections; using System.Globalization; using System.Linq; using System.Web.Mvc; using C1.Web.Mvc; using MvcExplorer.Models; using System.Collections.Generic; using C1.Web.Mvc.Serialization; namespace MvcExplorer.Controllers { public partial class FlexGridController : Controller { public static List<Sale> SALES = CustomerSale.GetData(100).ToList(); public ActionResult DataMap() { ViewBag.Countries = CustomerSale.NAMEDCOUNTRIES; ViewBag.Products = CustomerSale.PRODUCTS; ViewBag.Colors = CustomerSale.COLORS; ViewBag.Ranks = CustomerSale.RANKS; return View(SALES); } public ActionResult RemoteBindCustomerSale_Read([C1JsonRequest] CollectionViewRequest<Sale> requestData) { return this .C1Json(CollectionViewHelper.Read(requestData, SALES, (col)=> { if (col.Binding == "Country" ) { return CustomerSale.NAMEDCOUNTRIES; } if (col.Binding == "Product" ) { return CustomerSale.PRODUCTS; } if (col.Binding == "Color" ) { return CustomerSale.COLORS; } if (col.Binding == "Rank" ) { return CustomerSale.RANKS; } return null ; })); } public ActionResult ProductsUpdate([C1JsonRequest]CollectionViewEditRequest<Sale> requestData) { return this .C1Json(CollectionViewHelper.Edit<Sale>(requestData, sale => { string error = string .Empty; bool success = true ; var fSale = SALES.Find(item => item.ID == sale.ID); fSale.Active = sale.Active; fSale.Amount = sale.Amount; fSale.Color = sale.Color; fSale.Country = sale.Country; fSale.Discount = sale.Discount; fSale.End = sale.End; fSale.Amount2 = sale.Amount2; fSale.Start = sale.Start; fSale.Product = sale.Product; fSale.Rank = sale.Rank; return new CollectionViewItemResult<Sale> { Error = error, Success = success && ModelState.IsValid, Data = fSale }; }, () => SALES)); } } } |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | @using C1.Web.Mvc.Grid @model IEnumerable< Sale > @ { List< CustomerSale.NamedCountry > countries = ViewBag.Countries; List< CustomerSale.NamedProduct > products = ViewBag.Products; List< NamedColor > colors = ViewBag.Colors; List< CustomerSale.NamedRank > ranks = ViewBag.Ranks; ViewBag.DemoDescription = false ; } < h3 > @Html .Raw(Resources.FlexGrid.DataMap_DataMap) </ h3 > < p > @Html .Raw(Resources.FlexGrid.DataMap_Text0) @Html .Raw(Resources.FlexGrid.DataMap_Text1) </ p > @ (Html.C1().FlexGrid< Sale >() .Id( "ovFlexGrid" ) .AutoGenerateColumns( false ) .Bind(bl => bl.Bind(Url.Action( "RemoteBindCustomerSale_Read" )).Update(Url.Action( "ProductsUpdate" ))) .CssClass( "grid" ) .IsReadOnly( false ) .Columns(bl => { bl.Add(cb => cb.Binding( "ID" ).Visible( false )); 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" ).DataMapEditor(DataMapEditor.AutoComplete) .DataMap(dm => dm.DisplayMemberPath( "Name" ) .SelectedValuePath( "Name" ) .SortByDisplayValues( true ) .Bind(countries))); bl.Add(cb => cb.Binding( "Product" ).DataMapEditor(DataMapEditor.DropDownList) .DataMap(dm => dm.DisplayMemberPath( "Name" ) .SelectedValuePath( "Id" ) .SortByDisplayValues( true ) .Bind(products))); bl.Add(cb => cb.Binding( "Color" ).DataMapEditor(DataMapEditor.DropDownList) .DataMap(dm => dm.DisplayMemberPath( "Name" ) .SelectedValuePath( "Value" ) .SortByDisplayValues( true ) .Bind(colors))); 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" )); bl.Add(cb => cb.Binding( "Rank" ).Width( "250" ).Align( "center" ).DataMapEditor(DataMapEditor.RadioButtons) .DataMap(dm => dm.DisplayMemberPath( "Name" ) .SelectedValuePath( "Name" ) .SortByDisplayValues( true ) .Bind(ranks))); }) ) < h4 > @Html .Raw(Resources.FlexGrid.DataMap_MultiColumnDataMap) </ h4 > < p > @Html .Raw(Resources.FlexGrid.DataMap_Text2)</ p > < p > @Html .Raw(Resources.FlexGrid.DataMap_Text3)</ p > @ (Html.C1().FlexGrid< Sale >() .Id( "multiColumns" ) .AutoGenerateColumns( false ) .Bind(bl => bl.InitialItemsCount(100).Bind(Model).Update(Url.Action( "ProductsUpdate" ))) .CssClass( "grid" ) .IsReadOnly( false ) .Columns(bl => { bl.Add(cb => cb.Binding( "ID" ).Visible( false )); 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" ) .DataMap(dm => dm.DisplayMemberPath( "Name" ) .SelectedValuePath( "Id" ) .SortByDisplayValues( true ) .Bind(products))); bl.Add(cb => cb.Binding( "Color" ) .DropDownCssClass( "multi-column" ) .DataMap(dm => dm.DisplayMemberPath( "Name" ) .SelectedValuePath( "Value" ) .SortByDisplayValues( true ) .Bind(colors))); 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" )); }) ) < style > .wj-radio-map label { padding: 0 0 0 0; } </ style > |