-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
222 lines (219 loc) · 7.34 KB
/
index.html
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<!DOCTYPE html>
<html>
<head>
<title>DataGrid - How to apply custom sorting to a grouped column</title>
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.1.7/css/dx.common.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.1.7/css/dx.light.css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn3.devexpress.com/jslib/20.1.7/js/dx.all.js"></script>
<script type="text/javascript">
$(function () {
$("#gridContainer1").dxDataGrid({
dataSource: {
store: customers
},
keyExpr: 'ID',
showBorders: true,
grouping: {
autoExpandAll: true
},
groupPanel: {
visible: true
},
columns: [ "ID", "CompanyName", "City",
{
dataField: "State",
groupIndex: 0,
groupCellTemplate: function(element, options) {
let column = options.column;
let displayValue = options.value.split(";")[1];
element.text(column.caption + ": " + displayValue);
},
calculateGroupValue: function(rowData) {
let sortValue = rowData.State === "California" ? this.sortOrder !== "desc" ? "aaa" : "zzz" : rowData.State;
let displayValue = rowData.State;
return sortValue + ";" + displayValue;
}
}
],
});
var dataGrid = $("#gridContainer2").dxDataGrid({
dataSource: customers,
keyExpr: 'ID',
showBorders: true,
grouping: {
autoExpandAll: true
},
groupPanel: {
visible: true
},
paging: {
pageSize: 10
},
columns: [ "ID", "CompanyName", "City",
{
dataField: "State",
groupIndex: 0
},
{
name: "StateOrder",
calculateCellValue: function(rowData) {
return rowData.State === "California" ? dataGrid.columnOption("State", "sortOrder") !== "desc" ? "aaa" : "zzz" : rowData.State;
},
visible: false,
showInColumnChooser: false
}
],
summary: {
groupItems: [{
column: "StateOrder",
summaryType: "min",
alignByColumn: true
}]
},
sortByGroupSummaryInfo: [{
summaryItem: "StateOrder"
}],
}).dxDataGrid("instance");
});
let customers = [{
ID: 1,
CompanyName: "Super Mart of the West",
Address: "702 SW 8th Street",
City: "Bentonville",
State: "Arkansas",
StateNo: 5,
Zipcode: 72716,
Phone: "(800) 555-2797",
Fax: "(800) 555-2171",
Website: "http://www.nowebsitesupermart.com"
},
{
ID: 2,
CompanyName: "K&S Music",
Address: "1000 Nicllet Mall",
City: "Minneapolis",
State: "Minnesota",
StateNo: 1,
Zipcode: 55403,
Phone: "(612) 304-6073",
Fax: "(612) 304-6074",
Website: "http://www.nowebsitemusic.com"
},
{
ID: 3,
CompanyName: "Tom's Club",
Address: "999 Lake Drive",
City: "Issaquah",
State: "Washington",
StateNo: 2,
Zipcode: 98027,
Phone: "(800) 955-2292",
Fax: "(800) 955-2293",
Website: "http://www.nowebsitetomsclub.com"
},
{
ID: 4,
CompanyName: "E-Mart",
Address: "3333 Beverly Rd",
City: "Hoffman Estates",
State: "Illinois",
StateNo: 3,
Zipcode: 60179,
Phone: "(847) 286-2500",
Fax: "(847) 286-2501",
Website: "http://www.nowebsiteemart.com"
},
{
ID: 5,
CompanyName: "Walters",
Address: "200 Wilmot Rd",
City: "Deerfield",
State: "Illinois",
StateNo: 3,
Zipcode: 60015,
Phone: "(847) 940-2500",
Fax: "(847) 940-2501",
Website: "http://www.nowebsitewalters.com"
},
{
ID: 6,
CompanyName: "StereoShack",
Address: "400 Commerce S",
City: "Fort Worth",
State: "Texas",
StateNo: 4,
Zipcode: 76102,
Phone: "(817) 820-0741",
Fax: "(817) 820-0742",
Website: "http://www.nowebsiteshack.com"
},
{
ID: 7,
CompanyName: "Circuit Town",
Address: "2200 Kensington Court",
City: "Oak Brook",
State: "Illinois",
StateNo: 3,
Zipcode: 60523,
Phone: "(800) 955-2929",
Fax: "(800) 955-9392",
Website: "http://www.nowebsitecircuittown.com"
},
{
ID: 8,
CompanyName: "Premier Buy",
Address: "7601 Penn Avenue South",
City: "Richfield",
State: "Minnesota",
StateNo: 1,
Zipcode: 55423,
Phone: "(612) 291-1000",
Fax: "(612) 291-2001",
Website: "http://www.nowebsitepremierbuy.com"
},
{
ID: 9,
CompanyName: "ElectrixMax",
Address: "263 Shuman Blvd",
City: "Naperville",
State: "Illinois",
StateNo: 3,
Zipcode: 60563,
Phone: "(630) 438-7800",
Fax: "(630) 438-7801",
Website: "http://www.nowebsiteelectrixmax.com"
},
{
ID: 10,
CompanyName: "Video Emporium",
Address: "1201 Elm Street",
City: "Dallas",
State: "Texas",
StateNo: 4,
Zipcode: 75270,
Phone: "(214) 854-3000",
Fax: "(214) 854-3001",
Website: "http://www.nowebsitevideoemporium.com"
},
{
ID: 20,
CompanyName: "ACME",
Address: "2525 E El Segundo Blvd",
City: "El Segundo",
State: "California",
StateNo: 6,
Zipcode: 90245,
Phone: "(310) 536-0611",
Fax: "(310) 536-0612",
Website: "http://www.nowebsiteacme.com"
}];
</script>
</head>
<body>
<h2>The use of calculateGroupValue and groupCellTemplate</h2>
<div id="gridContainer1"></div>
<h2>The use of a calculated hidden column and Summary</h2>
<div id="gridContainer2"></div>
</body>
</html>