Features

Data Map

Data Map

This sample demonstrates how to use data map feature, which provides the MultiRow control with automatic look up capabilities.

Features

Data Map

Data maps provide a grid with automatic look up capabilities. For example, you may want to display a customer's name instead of his/her 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 show drop-down buttons that can be used for quick editing. If you do not want to show the drop-down buttons, set the column's ShowDropDown property to false.

ID
Start
Country
Color
Amount
Amount2
1
Jan 25 25
German
$581.61
($2,939.67)

 

Multi-column Data Map

The columns of MultiRow control have a DropDownCssClass property that enables styling 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:

ID
Start
Country
Color
Amount
Amount2
1
Jan 25 25
German
$581.61
($2,939.67)
00:00
Gadget
Charcoal
14 %
2
Feb 25 25
Canada
$4,919.02
($4,673.75)
01:01
Gadget
Black Cat
17 %
3
Mar 25 25
Japan
$2,159.73
($3,810.42)
02:02
Gadget
Brown
7 %
4
Apr 25 25
German
$1,248.66
($2,815.93)
03:03
Gadget
Gunmetal
22 %
5
May 25 25
German
$4,051.76
($3,108.76)
04:04
Gadget
Green
12 %
6
Jun 25 25
Canada
($3,131.28)
($4,314.81)
05:05
Gadget
LightBlue
16 %
7
Jul 25 25
China
$698.62
($2,745.97)
06:06
Widget
Gunmetal
15 %
8
Aug 25 25
US
$3,464.15
$1,131.58
07:07
Widget
Brown
3 %
9
Sep 25 25
Korea
($2,363.16)
$3,425.60
08:08
Gadget
White
14 %
10
Oct 25 25
US
($2,836.94)
($4,283.10)
09:09
Widget
Brown
6 %
11
Nov 25 25
France
$877.93
$2,722.02
10:10
Widget
Venom Green
8 %
12
Dec 25 25
Korea
($3,788.14)
($3,050.89)
11:11
Widget
Gunmetal
12 %
13
Jan 25 25
German
($2,446.92)
($2,351.67)
12:12
Gadget
Night
12 %
14
Feb 25 25
German
($4,374.97)
($3,899.38)
13:13
Widget
DarkBlue
18 %
15
Mar 25 25
Japan
$1,089.32
($4,102.95)
14:14
Gadget
Venom Green
16 %
16
Apr 25 25
China
$1,341.85
$532.34
15:15
Gadget
Cyan
8 %
17
May 25 25
US
$3,596.33
$623.80
16:16
Widget
Green
18 %
18
Jun 25 25
China
$3,232.11
$305.20
17:17
Widget
Black Cat
24 %
19
Jul 25 25
France
($2,008.99)
$1,805.09
18:18
Gadget
Columbia Blue
9 %
20
Aug 25 25
France
$2,568.01
$2,889.37
19:19
Gadget
Lime
3 %
21
Sep 25 25
UK
($3,476.95)
$4,852.50
20:20
Widget
White
1 %
22
Oct 25 25
UK
$2,290.56
$3,295.03
21:21
Widget
Gray
6 %
23
Nov 25 25
Japan
($4,146.76)
$853.06
22:22
Gadget
Maroon
1 %
24
Dec 25 25
Canada
$4,917.55
($4,479.39)
23:23
Gadget
Gray
14 %
25
Jan 25 25
Korea
$3,824.28
$2,007.51
00:24
Gadget
White
8 %
26
Feb 25 25
Japan
($4,257.83)
($1,652.26)
01:25
Gadget
Olive
23 %
27
Mar 25 25
Italy
$1,095.08
$1,413.34
02:26
Gadget
LightBlue
20 %
28
Apr 25 25
German
$1,853.66
$4,924.12
03:27
Gadget
Columbia Blue
18 %
29
May 25 25
Italy
$3,708.86
($2,697.08)
04:28
Widget
Magenta
3 %
30
Jun 25 25
Canada
($3,447.73)
$3,738.87
05:29
Gadget
Teal
10 %
31
Jul 25 25
German
($165.64)
($4,919.21)
06:30
Gadget
Olive
4 %
32
Aug 25 25
China
$160.62
$1,299.66
07:31
Widget
Lime
8 %
33
Sep 25 25
Korea
($2,575.30)
($1,036.23)
08:32
Widget
Orange
17 %
34
Oct 25 25
Italy
$3,288.12
($2,392.41)
09:33
Widget
Midnight
19 %
35
Nov 25 25
Korea
($4,563.28)
$1,361.51
10:34
Gadget
Gray
2 %
36
Dec 25 25
Canada
($4,839.71)
($1,835.02)
11:35
Widget
Olive
19 %
37
Jan 25 25
US
$544.13
($4,548.24)
12:36
Gadget
Midnight
10 %
38
Feb 25 25
Canada
$538.45
$1,848.22
13:37
Widget
Midnight
4 %
39
Mar 25 25
Japan
$1,493.10
$391.20
14:38
Gadget
Brown
19 %
40
Apr 25 25
US
($2,838.54)
$4,241.04
15:39
Widget
Green
14 %
41
May 25 25
UK
($3,175.21)
($2,650.41)
16:40
Gadget
DarkBlue
18 %
42
Jun 25 25
France
$22.88
($2,410.67)
17:41
Widget
Red
17 %
43
Jul 25 25
Korea
($4,129.88)
($3,660.62)
18:42
Widget
Cyan
17 %
44
Aug 25 25
Korea
$2,170.82
($3,562.14)
19:43
Gadget
Oil
14 %
45
Sep 25 25
Korea
($3,000.98)
($238.75)
20:44
Gadget
Midnight
9 %
46
Oct 25 25
US
$3,374.49
($4,629.37)
21:45
Gadget
Night
23 %
47
Nov 25 25
Canada
($2,103.52)
($4,860.82)
22:46
Widget
Charcoal
23 %
48
Dec 25 25
German
($2,077.64)
($4,678.39)
23:47
Widget
Orange
6 %
49
Jan 25 25
France
($748.11)
$1,463.78
00:48
Gadget
Venom Green
14 %
50
Feb 25 25
German
$678.23
$95.72
01:49
Widget
Orange
3 %
51
Mar 25 25
Italy
$4,420.76
($4,654.08)
02:50
Gadget
Olive
1 %
52
Apr 25 25
China
($4,161.96)
$272.81
03:51
Widget
Orange
7 %
53
May 25 25
China
($4,266.09)
($4,920.97)
04:52
Gadget
Midnight
6 %
54
Jun 25 25
Korea
($3,422.65)
$2,304.34
05:53
Gadget
Oil
22 %
55
Jul 25 25
China
($185.37)
($280.05)
06:54
Gadget
Gunmetal
12 %
56
Aug 25 25
US
($4,675.00)
$4,759.93
07:55
Widget
Charcoal
9 %
57
Sep 25 25
Canada
($1,746.26)
($780.98)
08:56
Gadget
Red
19 %
58
Oct 25 25
German
($3,518.88)
($2,779.71)
09:57
Widget
Teal
5 %
59
Nov 25 25
Canada
($228.15)
$3,505.17
10:58
Widget
Gunmetal
20 %
60
Dec 25 25
Italy
($839.21)
$1,002.81
11:59
Widget
Orange
21 %
61
Jan 25 25
US
$2,042.44
$1,010.09
12:00
Widget
White
2 %
62
Feb 25 25
US
$4,568.40
$2,813.06
13:01
Gadget
Olive
21 %
63
Mar 25 25
Korea
$595.84
($369.24)
14:02
Widget
Magenta
4 %
64
Apr 25 25
Canada
($2,520.97)
$31.56
15:03
Gadget
Night
9 %
65
May 25 25
Korea
$3,017.71
$2,732.26
16:04
Gadget
Lime
12 %
66
Jun 25 25
Korea
($3,412.10)
$3,802.04
17:05
Widget
Silver
22 %
67
Jul 25 25
Korea
($3,256.14)
($3,342.69)
18:06
Gadget
Maroon
0 %
68
Aug 25 25
China
$4,334.98
($1,274.35)
19:07
Gadget
Magenta
17 %
69
Sep 25 25
China
($989.05)
($4,651.12)
20:08
Widget
Black
9 %
70
Oct 25 25
US
$2,673.11
($1,656.47)
21:09
Widget
Silver
1 %
71
Nov 25 25
Japan
$4,676.20
($2,435.42)
22:10
Gadget
Columbia Blue
4 %
72
Dec 25 25
German
($4,427.85)
($952.53)
23:11
Widget
Cyan
13 %
73
Jan 25 25
Japan
($4,916.10)
($507.49)
00:12
Gadget
Orange
19 %
74
Feb 25 25
China
($1,940.69)
($2,854.91)
01:13
Widget
Purple
0 %
75
Mar 25 25
German
($862.78)
$4,355.25
02:14
Widget
Maroon
10 %
76
Apr 25 25
Canada
$2,015.45
($1,489.64)
03:15
Gadget
Purple
25 %
77
May 25 25
Japan
$4,585.00
($2,963.00)
04:16
Gadget
Purple
16 %
78
Jun 25 25
US
$1,986.58
$606.61
05:17
Widget
Brown
6 %
79
Jul 25 25
US
($3,469.64)
($1,856.72)
06:18
Widget
Cyan
25 %
80
Aug 25 25
German
$2,342.70
($3,639.94)
07:19
Gadget
Brown
5 %
81
Sep 25 25
UK
$4,479.22
($842.31)
08:20
Gadget
Gunmetal
21 %
82
Oct 25 25
US
$2,869.30
$3,725.41
09:21
Gadget
Iridium
12 %
83
Nov 25 25
US
($2,190.02)
($2,736.44)
10:22
Gadget
Black
18 %
84
Dec 25 25
Italy
$322.50
($3,277.44)
11:23
Widget
White
23 %
85
Jan 25 25
France
($1,479.40)
$3,151.24
12:24
Widget
Midnight
12 %
86
Feb 25 25
Italy
$3,689.48
($1,072.41)
13:25
Widget
DarkBlue
10 %
87
Mar 25 25
Canada
($1,241.87)
$2,966.15
14:26
Widget
Venom Green
24 %
88
Apr 25 25
Japan
$4,009.94
($3,149.85)
15:27
Gadget
Yellow
11 %
89
May 25 25
Japan
$2,323.39
$444.47
16:28
Gadget
Gray
16 %
90
Jun 25 25
Italy
($1,227.88)
$1,787.36
17:29
Gadget
Venom Green
12 %
91
Jul 25 25
German
($456.57)
$2,388.73
18:30
Widget
Magenta
20 %
92
Aug 25 25
Italy
($992.57)
($1,438.44)
19:31
Widget
White
25 %
93
Sep 25 25
Canada
($4,707.05)
($1,935.98)
20:32
Gadget
DarkBlue
19 %
94
Oct 25 25
US
$2,301.03
$1,134.37
21:33
Widget
Oil
24 %
95
Nov 25 25
German
($1,062.14)
$2,694.52
22:34
Gadget
Venom Green
5 %
96
Dec 25 25
France
($587.13)
$974.87
23:35
Widget
White
4 %
97
Jan 25 25
US
$2,518.17
$1,421.02
00:36
Gadget
Magenta
19 %
98
Feb 25 25
Japan
$4,900.51
$3,229.92
01:37
Widget
Gunmetal
16 %
99
Mar 25 25
Japan
$2,920.44
$4,808.53
02:38
Gadget
Lime
0 %
100
Apr 25 25
France
$568.63
$329.90
03:39
Widget
Charcoal
13 %
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
using System;
using System.Collections;
using System.Globalization;
using System.Linq;
using System.Web.Mvc;
using C1.Web.Mvc;
using MultiRowExplorer.Models;
using System.Collections.Generic;
using C1.Web.Mvc.Serialization;
 
 
namespace MultiRowExplorer.Controllers
{
    public partial class MultiRowController : Controller
    {
        public static List<Sale> SALES = CustomerSale.GetData(100).ToList();
        public ActionResult DataMap()
        {
            ViewBag.Products = CustomerSale.PRODUCTS;
            ViewBag.Colors = CustomerSale.COLORS;
            return View(SALES);
        }
 
        public ActionResult RemoteBindCustomerSale_Read([C1JsonRequest] CollectionViewRequest<Sale> requestData)
        {
            return this.C1Json(CollectionViewHelper.Read(requestData, SALES, (col) =>
            {
                var cell = col as C1.Web.Mvc.MultiRow.CellInfo;
 
                if (cell.Binding == "Product")
                {
                    return CustomerSale.PRODUCTS;
                }
 
                if (cell.Binding == "Color")
                {
                    return CustomerSale.COLORS;
                }
 
                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;
                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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
@using C1.Web.Mvc.Grid
 
@model IEnumerable<Sale>
@{
    List<CustomerSale.NamedProduct> products = ViewBag.Products;
    List<NamedColor> colors = ViewBag.Colors;
    ViewBag.DemoDescription = false;
}
<h3>
    Data Map
</h3>
<p>
    Data maps provide a grid with automatic look up capabilities. For example, you may want to display a customer's name instead of his/her ID, or a color name instead of its RGB value.<br />
    Columns with an associated data map can be sorted by the mapped display value instead of the binding value.<br />
    Columns with an associated data map show drop-down buttons that can be used for quick editing. If you do not want to show the drop-down buttons, set the column's <b>ShowDropDown</b> property to false.
</p>
@(Html.C1().MultiRow<Sale>()
    .Id("dmMultiRow")
    .Bind(bl => bl.Bind(Url.Action("RemoteBindCustomerSale_Read")).Update(Url.Action("ProductsUpdate")))
    .CssClass("multirow")
    .IsReadOnly(false)
    .LayoutDefinition(ld =>
    {
        ld.Add().Colspan(1).Cells(bl =>
        {
            bl.Add(cb => cb.Binding("ID").IsReadOnly(true));
            bl.Add(cb => cb.Binding("Active"));
 
        });
        ld.Add().Colspan(1).Cells(bl =>
        {
            bl.Add(cb => cb.Binding("Start").Format("MMM d yy"));
            bl.Add(cb => cb.Binding("End").Format("HH:mm"));
        });
        ld.Add().Colspan(2).Cells(bl =>
        {
            bl.Add(cb => cb.Binding("Country").Colspan(2));
            bl.Add(cb => cb.Binding("Product")
                .DataMap(dm => dm.DisplayMemberPath("Name")
                    .SelectedValuePath("Id")
                    .SortByDisplayValues(true)
                    .Bind(products)));
            bl.Add(cb => cb.Binding("Color")
                .DataMap(dm => dm.DisplayMemberPath("Name")
                    .SelectedValuePath("Value")
                    .SortByDisplayValues(true)
                    .Bind(colors)));
        });
        ld.Add().Colspan(2).Cells(bl =>
        {
            bl.Add(cb => cb.Binding("Amount").Format("c"));
            bl.Add(cb => cb.Binding("Amount2").Format("c"));
            bl.Add(cb => cb.Binding("Discount").Format("p0").Colspan(2));
 
        });
    })
)
<p>&nbsp;</p>
<h4>
    Multi-column Data Map
</h4>
<p>
    The columns of <b>MultiRow</b> control have a <b>DropDownCssClass</b> property that enables styling the drop-downs used to edit values in data-mapped columns.
</p>
<p>
    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:
</p>
@(Html.C1().MultiRow<Sale>()
    .Id("dmMultiColumns")
    .Bind(bl => bl.InitialItemsCount(100).Bind(Model).Update(Url.Action("ProductsUpdate")))
    .CssClass("multirow")
    .IsReadOnly(false)
    .LayoutDefinition(ld =>
    {
        ld.Add().Colspan(1).Cells(bl =>
        {
            bl.Add(cb => cb.Binding("ID").IsReadOnly(true));
            bl.Add(cb => cb.Binding("Active"));
 
        });
        ld.Add().Colspan(1).Cells(bl =>
        {
            bl.Add(cb => cb.Binding("Start").Format("MMM d yy"));
            bl.Add(cb => cb.Binding("End").Format("HH:mm"));
        });
        ld.Add().Colspan(2).Cells(bl =>
        {
            bl.Add(cb => cb.Binding("Country").Colspan(2));
            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)));
        });
        ld.Add().Colspan(2).Cells(bl =>
        {
            bl.Add(cb => cb.Binding("Amount").Format("c"));
            bl.Add(cb => cb.Binding("Amount2").Format("c"));
            bl.Add(cb => cb.Binding("Discount").Format("p0").Colspan(2));
 
        });
    })
)
 
@section Summary{
    This sample demonstrates how to use data map feature, which provides the MultiRow control with automatic look up capabilities.
}