tabulator-tables 5.3.0 → 5.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bower.json +1 -1
- package/dist/css/tabulator_bootstrap3.css +1 -1
- package/dist/css/tabulator_bootstrap3.css.map +1 -1
- package/dist/css/tabulator_bootstrap3.min.css +1 -1
- package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap4.css +4 -4
- package/dist/css/tabulator_bootstrap4.css.map +1 -1
- package/dist/css/tabulator_bootstrap4.min.css +1 -1
- package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap5.css +4 -4
- package/dist/css/tabulator_bootstrap5.css.map +1 -1
- package/dist/css/tabulator_bootstrap5.min.css +1 -1
- package/dist/css/tabulator_bootstrap5.min.css.map +1 -1
- package/dist/js/tabulator.js +304 -233
- package/dist/js/tabulator.js.map +1 -1
- package/dist/js/tabulator.min.js +2 -2
- package/dist/js/tabulator.min.js.map +1 -1
- package/dist/js/tabulator_esm.js +456 -388
- package/dist/js/tabulator_esm.js.map +1 -1
- package/dist/js/tabulator_esm.min.js +2 -2
- package/dist/js/tabulator_esm.min.js.map +1 -1
- package/package.json +1 -1
- package/src/js/core/ColumnManager.js +18 -4
- package/src/js/core/Module.js +54 -23
- package/src/js/core/RowManager.js +83 -94
- package/src/js/core/Tabulator.js +2 -2
- package/src/js/core/column/Column.js +26 -2
- package/src/js/core/tools/InteractionMonitor.js +12 -9
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +1 -1
- package/src/js/modules/DataTree/DataTree.js +5 -11
- package/src/js/modules/Edit/List.js +1 -1
- package/src/js/modules/Filter/Filter.js +3 -0
- package/src/js/modules/GroupRows/Group.js +5 -9
- package/src/js/modules/GroupRows/GroupComponent.js +1 -1
- package/src/js/modules/GroupRows/GroupRows.js +217 -194
- package/src/js/modules/History/History.js +1 -1
- package/src/js/modules/Interaction/Interaction.js +3 -3
- package/src/js/modules/Layout/defaults/modes/fitColumns.js +4 -6
- package/src/js/modules/Page/Page.js +2 -12
- package/src/js/modules/Persistence/Persistence.js +3 -2
- package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +3 -2
- package/src/js/modules/SelectRow/SelectRow.js +8 -4
- package/src/js/modules/Sort/Sort.js +4 -7
- package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +1 -1
- package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +1 -1
- package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +1 -1
|
@@ -3,20 +3,19 @@ import Module from '../../core/Module.js';
|
|
|
3
3
|
import Group from './Group.js';
|
|
4
4
|
|
|
5
5
|
class GroupRows extends Module{
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
constructor(table){
|
|
8
8
|
super(table);
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
this.groupIDLookups = false; //enable table grouping and set field to group by
|
|
11
11
|
this.startOpen = [function(){return false;}]; //starting state of group
|
|
12
12
|
this.headerGenerator = [function(){return "";}];
|
|
13
13
|
this.groupList = []; //ordered list of groups
|
|
14
14
|
this.allowedValues = false;
|
|
15
15
|
this.groups = {}; //hold row groups
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
|
|
18
17
|
this.displayHandler = this.getRows.bind(this);
|
|
19
|
-
|
|
18
|
+
|
|
20
19
|
//register table options
|
|
21
20
|
this.registerTableOption("groupBy", false); //enable table grouping and set field to group by
|
|
22
21
|
this.registerTableOption("groupStartOpen", true); //starting state of group
|
|
@@ -29,7 +28,7 @@ class GroupRows extends Module{
|
|
|
29
28
|
this.registerTableOption("groupHeaderDownload", null);
|
|
30
29
|
this.registerTableOption("groupToggleElement", "arrow");
|
|
31
30
|
this.registerTableOption("groupClosedShowCalcs", false);
|
|
32
|
-
|
|
31
|
+
|
|
33
32
|
//register table functions
|
|
34
33
|
this.registerTableFunction("setGroupBy", this.setGroupBy.bind(this));
|
|
35
34
|
this.registerTableFunction("setGroupValues", this.setGroupValues.bind(this));
|
|
@@ -37,11 +36,11 @@ class GroupRows extends Module{
|
|
|
37
36
|
this.registerTableFunction("setGroupHeader", this.setGroupHeader.bind(this));
|
|
38
37
|
this.registerTableFunction("getGroups", this.userGetGroups.bind(this));
|
|
39
38
|
this.registerTableFunction("getGroupedData", this.userGetGroupedData.bind(this));
|
|
40
|
-
|
|
39
|
+
|
|
41
40
|
//register component functions
|
|
42
41
|
this.registerComponentFunction("row", "getGroup", this.rowGetGroup.bind(this));
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
|
|
45
44
|
//initialize group configuration
|
|
46
45
|
initialize(){
|
|
47
46
|
if(this.table.options.groupBy){
|
|
@@ -49,7 +48,7 @@ class GroupRows extends Module{
|
|
|
49
48
|
this.subscribe("cell-value-updated", this.cellUpdated.bind(this));
|
|
50
49
|
this.subscribe("row-data-changed", this.reassignRowToGroup.bind(this), 0);
|
|
51
50
|
}
|
|
52
|
-
|
|
51
|
+
|
|
53
52
|
this.subscribe("table-built", this.configureGroupSetup.bind(this));
|
|
54
53
|
|
|
55
54
|
this.subscribe("row-deleting", this.rowDeleting.bind(this));
|
|
@@ -59,73 +58,73 @@ class GroupRows extends Module{
|
|
|
59
58
|
this.subscribe("rows-added", this.rowsUpdated.bind(this));
|
|
60
59
|
this.subscribe("row-moving", this.rowMoving.bind(this));
|
|
61
60
|
this.subscribe("row-adding-index", this.rowAddingIndex.bind(this));
|
|
62
|
-
|
|
61
|
+
|
|
63
62
|
this.subscribe("rows-sample", this.rowSample.bind(this));
|
|
64
|
-
|
|
63
|
+
|
|
65
64
|
this.subscribe("render-virtual-fill", this.virtualRenderFill.bind(this));
|
|
66
|
-
|
|
65
|
+
|
|
67
66
|
this.registerDisplayHandler(this.displayHandler, 20);
|
|
68
|
-
|
|
67
|
+
|
|
69
68
|
this.initialized = true;
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
|
-
|
|
71
|
+
|
|
73
72
|
configureGroupSetup(){
|
|
74
73
|
if(this.table.options.groupBy){
|
|
75
74
|
var groupBy = this.table.options.groupBy,
|
|
76
75
|
startOpen = this.table.options.groupStartOpen,
|
|
77
76
|
groupHeader = this.table.options.groupHeader;
|
|
78
|
-
|
|
77
|
+
|
|
79
78
|
this.allowedValues = this.table.options.groupValues;
|
|
80
|
-
|
|
79
|
+
|
|
81
80
|
if(Array.isArray(groupBy) && Array.isArray(groupHeader) && groupBy.length > groupHeader.length){
|
|
82
81
|
console.warn("Error creating group headers, groupHeader array is shorter than groupBy array");
|
|
83
82
|
}
|
|
84
|
-
|
|
83
|
+
|
|
85
84
|
this.headerGenerator = [function(){return "";}];
|
|
86
85
|
this.startOpen = [function(){return false;}]; //starting state of group
|
|
87
|
-
|
|
86
|
+
|
|
88
87
|
this.langBind("groups|item", (langValue, lang) => {
|
|
89
88
|
this.headerGenerator[0] = (value, count, data) => { //header layout function
|
|
90
89
|
return (typeof value === "undefined" ? "" : value) + "<span>(" + count + " " + ((count === 1) ? langValue : lang.groups.items) + ")</span>";
|
|
91
90
|
};
|
|
92
91
|
});
|
|
93
|
-
|
|
92
|
+
|
|
94
93
|
this.groupIDLookups = [];
|
|
95
|
-
|
|
94
|
+
|
|
96
95
|
if(Array.isArray(groupBy)){
|
|
97
96
|
if(this.table.modExists("columnCalcs") && this.table.options.columnCalcs != "table" && this.table.options.columnCalcs != "both"){
|
|
98
97
|
this.table.modules.columnCalcs.removeCalcs();
|
|
99
98
|
}
|
|
100
99
|
}else{
|
|
101
100
|
if(this.table.modExists("columnCalcs") && this.table.options.columnCalcs != "group"){
|
|
102
|
-
|
|
101
|
+
|
|
103
102
|
var cols = this.table.columnManager.getRealColumns();
|
|
104
|
-
|
|
103
|
+
|
|
105
104
|
cols.forEach((col) => {
|
|
106
105
|
if(col.definition.topCalc){
|
|
107
106
|
this.table.modules.columnCalcs.initializeTopRow();
|
|
108
107
|
}
|
|
109
|
-
|
|
108
|
+
|
|
110
109
|
if(col.definition.bottomCalc){
|
|
111
110
|
this.table.modules.columnCalcs.initializeBottomRow();
|
|
112
111
|
}
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
|
-
|
|
115
|
+
|
|
117
116
|
if(!Array.isArray(groupBy)){
|
|
118
117
|
groupBy = [groupBy];
|
|
119
118
|
}
|
|
120
|
-
|
|
119
|
+
|
|
121
120
|
groupBy.forEach((group, i) => {
|
|
122
121
|
var lookupFunc, column;
|
|
123
|
-
|
|
122
|
+
|
|
124
123
|
if(typeof group == "function"){
|
|
125
124
|
lookupFunc = group;
|
|
126
125
|
}else{
|
|
127
126
|
column = this.table.columnManager.getColumnByField(group);
|
|
128
|
-
|
|
127
|
+
|
|
129
128
|
if(column){
|
|
130
129
|
lookupFunc = function(data){
|
|
131
130
|
return column.getFieldValue(data);
|
|
@@ -136,26 +135,26 @@ class GroupRows extends Module{
|
|
|
136
135
|
};
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
|
-
|
|
138
|
+
|
|
140
139
|
this.groupIDLookups.push({
|
|
141
140
|
field: typeof group === "function" ? false : group,
|
|
142
141
|
func:lookupFunc,
|
|
143
142
|
values:this.allowedValues ? this.allowedValues[i] : false,
|
|
144
143
|
});
|
|
145
144
|
});
|
|
146
|
-
|
|
145
|
+
|
|
147
146
|
if(startOpen){
|
|
148
147
|
if(!Array.isArray(startOpen)){
|
|
149
148
|
startOpen = [startOpen];
|
|
150
149
|
}
|
|
151
|
-
|
|
150
|
+
|
|
152
151
|
startOpen.forEach((level) => {
|
|
153
152
|
level = typeof level == "function" ? level : function(){return true;};
|
|
154
153
|
});
|
|
155
|
-
|
|
154
|
+
|
|
156
155
|
this.startOpen = startOpen;
|
|
157
156
|
}
|
|
158
|
-
|
|
157
|
+
|
|
159
158
|
if(groupHeader){
|
|
160
159
|
this.headerGenerator = Array.isArray(groupHeader) ? groupHeader : [groupHeader];
|
|
161
160
|
}
|
|
@@ -164,218 +163,216 @@ class GroupRows extends Module{
|
|
|
164
163
|
this.groups = {};
|
|
165
164
|
}
|
|
166
165
|
}
|
|
167
|
-
|
|
166
|
+
|
|
168
167
|
rowSample(rows, prevValue){
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
if(this.table.options.groupBy){
|
|
169
|
+
var group = this.getGroups(false)[0];
|
|
170
|
+
|
|
171
|
+
prevValue.push(group.getRows(false)[0]);
|
|
172
|
+
}
|
|
173
|
+
|
|
173
174
|
return prevValue;
|
|
174
175
|
}
|
|
175
|
-
|
|
176
|
+
|
|
176
177
|
virtualRenderFill(){
|
|
177
178
|
var el = this.table.rowManager.tableElement;
|
|
178
179
|
var rows = this.table.rowManager.getVisibleRows();
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
// }
|
|
190
|
-
// }
|
|
180
|
+
|
|
181
|
+
if(this.table.options.groupBy){
|
|
182
|
+
rows = rows.filter((row) => {
|
|
183
|
+
return row.type !== "group";
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
el.style.minWidth = !rows.length ? this.table.columnManager.getWidth() + "px" : "";
|
|
187
|
+
}else{
|
|
188
|
+
return rows;
|
|
189
|
+
}
|
|
191
190
|
}
|
|
192
|
-
|
|
191
|
+
|
|
193
192
|
rowAddingIndex(row, index, top){
|
|
194
|
-
this.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if(
|
|
200
|
-
if(
|
|
201
|
-
if(
|
|
202
|
-
|
|
203
|
-
|
|
193
|
+
if(this.table.options.groupBy){
|
|
194
|
+
this.assignRowToGroup(row);
|
|
195
|
+
|
|
196
|
+
var groupRows = row.modules.group.rows;
|
|
197
|
+
|
|
198
|
+
if(groupRows.length > 1){
|
|
199
|
+
if(!index || (index && groupRows.indexOf(index) == -1)){
|
|
200
|
+
if(top){
|
|
201
|
+
if(groupRows[0] !== row){
|
|
202
|
+
index = groupRows[0];
|
|
203
|
+
this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top);
|
|
204
|
+
}
|
|
205
|
+
}else{
|
|
206
|
+
if(groupRows[groupRows.length -1] !== row){
|
|
207
|
+
index = groupRows[groupRows.length -1];
|
|
208
|
+
this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top);
|
|
209
|
+
}
|
|
204
210
|
}
|
|
205
211
|
}else{
|
|
206
|
-
|
|
207
|
-
index = groupRows[groupRows.length -1];
|
|
208
|
-
this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top);
|
|
209
|
-
}
|
|
212
|
+
this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top);
|
|
210
213
|
}
|
|
211
|
-
}else{
|
|
212
|
-
this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top);
|
|
213
214
|
}
|
|
215
|
+
|
|
216
|
+
return index;
|
|
214
217
|
}
|
|
215
|
-
|
|
216
|
-
return index;
|
|
217
218
|
}
|
|
218
|
-
|
|
219
|
+
|
|
219
220
|
trackChanges(){
|
|
220
221
|
this.dispatch("group-changed");
|
|
221
222
|
}
|
|
222
|
-
|
|
223
|
+
|
|
223
224
|
///////////////////////////////////
|
|
224
225
|
///////// Table Functions /////////
|
|
225
226
|
///////////////////////////////////
|
|
226
|
-
|
|
227
|
+
|
|
227
228
|
setGroupBy(groups){
|
|
228
229
|
this.table.options.groupBy = groups;
|
|
229
|
-
|
|
230
|
+
|
|
230
231
|
if(!this.initialized){
|
|
231
232
|
this.initialize();
|
|
232
233
|
}
|
|
233
|
-
|
|
234
|
+
|
|
234
235
|
this.configureGroupSetup();
|
|
235
|
-
|
|
236
|
+
|
|
236
237
|
this.refreshData();
|
|
237
|
-
|
|
238
|
+
|
|
238
239
|
this.trackChanges();
|
|
239
240
|
}
|
|
240
|
-
|
|
241
|
+
|
|
241
242
|
setGroupValues(groupValues){
|
|
242
243
|
this.table.options.groupValues = groupValues;
|
|
243
244
|
this.configureGroupSetup();
|
|
244
245
|
this.refreshData();
|
|
245
|
-
|
|
246
|
+
|
|
246
247
|
this.trackChanges();
|
|
247
248
|
}
|
|
248
|
-
|
|
249
|
+
|
|
249
250
|
setGroupStartOpen(values){
|
|
250
251
|
this.table.options.groupStartOpen = values;
|
|
251
252
|
this.configureGroupSetup();
|
|
252
|
-
|
|
253
|
+
|
|
253
254
|
if(this.table.options.groupBy){
|
|
254
255
|
this.refreshData();
|
|
255
|
-
|
|
256
|
+
|
|
256
257
|
this.trackChanges();
|
|
257
258
|
}else{
|
|
258
259
|
console.warn("Grouping Update - cant refresh view, no groups have been set");
|
|
259
260
|
}
|
|
260
261
|
}
|
|
261
|
-
|
|
262
|
+
|
|
262
263
|
setGroupHeader(values){
|
|
263
264
|
this.table.options.groupHeader = values;
|
|
264
265
|
this.configureGroupSetup();
|
|
265
|
-
|
|
266
|
+
|
|
266
267
|
if(this.table.options.groupBy){
|
|
267
268
|
this.refreshData();
|
|
268
|
-
|
|
269
|
+
|
|
269
270
|
this.trackChanges();
|
|
270
271
|
}else{
|
|
271
272
|
console.warn("Grouping Update - cant refresh view, no groups have been set");
|
|
272
273
|
}
|
|
273
274
|
}
|
|
274
|
-
|
|
275
|
+
|
|
275
276
|
userGetGroups(values){
|
|
276
277
|
return this.getGroups(true);
|
|
277
278
|
}
|
|
278
|
-
|
|
279
|
+
|
|
279
280
|
// get grouped table data in the same format as getData()
|
|
280
281
|
userGetGroupedData(){
|
|
281
282
|
return this.table.options.groupBy ?
|
|
282
|
-
|
|
283
|
+
this.getGroupedData() : this.getData();
|
|
283
284
|
}
|
|
284
|
-
|
|
285
|
-
|
|
285
|
+
|
|
286
|
+
|
|
286
287
|
///////////////////////////////////////
|
|
287
288
|
///////// Component Functions /////////
|
|
288
289
|
///////////////////////////////////////
|
|
289
|
-
|
|
290
|
+
|
|
290
291
|
rowGetGroup(row){
|
|
291
292
|
return row.modules.group ? row.modules.group.getComponent() : false;
|
|
292
293
|
}
|
|
293
|
-
|
|
294
|
+
|
|
294
295
|
///////////////////////////////////
|
|
295
296
|
///////// Internal Logic //////////
|
|
296
297
|
///////////////////////////////////
|
|
297
|
-
|
|
298
|
+
|
|
298
299
|
rowMoving(from, to, after){
|
|
299
|
-
if(
|
|
300
|
-
to
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
fromGroup
|
|
300
|
+
if(this.table.options.groupBy){
|
|
301
|
+
if(!after && to instanceof Group){
|
|
302
|
+
to = this.table.rowManager.prevDisplayRow(from) || to;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
var toGroup = to instanceof Group ? to : to.modules.group;
|
|
306
|
+
var fromGroup = from instanceof Group ? from : from.modules.group;
|
|
307
|
+
|
|
308
|
+
if(toGroup === fromGroup){
|
|
309
|
+
this.table.rowManager.moveRowInArray(toGroup.rows, from, to, after);
|
|
310
|
+
}else{
|
|
311
|
+
if(fromGroup){
|
|
312
|
+
fromGroup.removeRow(from);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
toGroup.insertRow(from, to, after);
|
|
311
316
|
}
|
|
312
|
-
|
|
313
|
-
toGroup.insertRow(from, to, after);
|
|
314
317
|
}
|
|
315
318
|
}
|
|
316
|
-
|
|
317
|
-
|
|
319
|
+
|
|
320
|
+
|
|
318
321
|
rowDeleting(row){
|
|
319
322
|
//remove from group
|
|
320
|
-
if(row.modules.group){
|
|
323
|
+
if(this.table.options.groupBy && row.modules.group){
|
|
321
324
|
row.modules.group.removeRow(row);
|
|
322
325
|
}
|
|
323
326
|
}
|
|
324
|
-
|
|
325
|
-
|
|
327
|
+
|
|
326
328
|
rowsUpdated(row){
|
|
327
|
-
this.
|
|
329
|
+
if(this.table.options.groupBy){
|
|
330
|
+
this.updateGroupRows(true);
|
|
331
|
+
}
|
|
328
332
|
}
|
|
329
|
-
|
|
333
|
+
|
|
330
334
|
cellUpdated(cell){
|
|
331
|
-
this.
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
setDisplayIndex(index){
|
|
336
|
-
this.displayIndex = index;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
getDisplayIndex(){
|
|
340
|
-
return this.displayIndex;
|
|
335
|
+
if(this.table.options.groupBy){
|
|
336
|
+
this.reassignRowToGroup(cell.row);
|
|
337
|
+
}
|
|
341
338
|
}
|
|
342
|
-
|
|
339
|
+
|
|
343
340
|
//return appropriate rows with group headers
|
|
344
341
|
getRows(rows){
|
|
345
342
|
if(this.table.options.groupBy && this.groupIDLookups.length){
|
|
346
|
-
|
|
343
|
+
|
|
347
344
|
this.dispatchExternal("dataGrouping");
|
|
348
|
-
|
|
345
|
+
|
|
349
346
|
this.generateGroups(rows);
|
|
350
|
-
|
|
347
|
+
|
|
351
348
|
if(this.subscribedExternal("dataGrouped")){
|
|
352
349
|
this.dispatchExternal("dataGrouped", this.getGroups(true));
|
|
353
350
|
}
|
|
354
|
-
|
|
351
|
+
|
|
355
352
|
return this.updateGroupRows();
|
|
356
|
-
|
|
353
|
+
|
|
357
354
|
}else{
|
|
358
355
|
return rows.slice(0);
|
|
359
356
|
}
|
|
360
357
|
}
|
|
361
|
-
|
|
358
|
+
|
|
362
359
|
getGroups(component){
|
|
363
360
|
var groupComponents = [];
|
|
364
|
-
|
|
361
|
+
|
|
365
362
|
this.groupList.forEach(function(group){
|
|
366
363
|
groupComponents.push(component ? group.getComponent() : group);
|
|
367
364
|
});
|
|
368
|
-
|
|
365
|
+
|
|
369
366
|
return groupComponents;
|
|
370
367
|
}
|
|
371
|
-
|
|
368
|
+
|
|
372
369
|
getChildGroups(group){
|
|
373
370
|
var groupComponents = [];
|
|
374
|
-
|
|
371
|
+
|
|
375
372
|
if(!group){
|
|
376
373
|
group = this;
|
|
377
374
|
}
|
|
378
|
-
|
|
375
|
+
|
|
379
376
|
group.groupList.forEach((child) => {
|
|
380
377
|
if(child.groupList.length){
|
|
381
378
|
groupComponents = groupComponents.concat(this.getChildGroups(child));
|
|
@@ -383,91 +380,93 @@ class GroupRows extends Module{
|
|
|
383
380
|
groupComponents.push(child);
|
|
384
381
|
}
|
|
385
382
|
});
|
|
386
|
-
|
|
383
|
+
|
|
387
384
|
return groupComponents;
|
|
388
385
|
}
|
|
389
|
-
|
|
386
|
+
|
|
390
387
|
wipe(){
|
|
391
|
-
this.
|
|
392
|
-
|
|
393
|
-
|
|
388
|
+
if(this.table.options.groupBy){
|
|
389
|
+
this.groupList.forEach(function(group){
|
|
390
|
+
group.wipe();
|
|
391
|
+
});
|
|
392
|
+
}
|
|
394
393
|
}
|
|
395
|
-
|
|
394
|
+
|
|
396
395
|
pullGroupListData(groupList) {
|
|
397
396
|
var groupListData = [];
|
|
398
|
-
|
|
397
|
+
|
|
399
398
|
groupList.forEach((group) => {
|
|
400
399
|
var groupHeader = {};
|
|
401
400
|
groupHeader.level = 0;
|
|
402
401
|
groupHeader.rowCount = 0;
|
|
403
402
|
groupHeader.headerContent = "";
|
|
404
403
|
var childData = [];
|
|
405
|
-
|
|
404
|
+
|
|
406
405
|
if (group.hasSubGroups) {
|
|
407
406
|
childData = this.pullGroupListData(group.groupList);
|
|
408
|
-
|
|
407
|
+
|
|
409
408
|
groupHeader.level = group.level;
|
|
410
409
|
groupHeader.rowCount = childData.length - group.groupList.length; // data length minus number of sub-headers
|
|
411
410
|
groupHeader.headerContent = group.generator(group.key, groupHeader.rowCount, group.rows, group);
|
|
412
|
-
|
|
411
|
+
|
|
413
412
|
groupListData.push(groupHeader);
|
|
414
413
|
groupListData = groupListData.concat(childData);
|
|
415
414
|
}
|
|
416
|
-
|
|
415
|
+
|
|
417
416
|
else {
|
|
418
417
|
groupHeader.level = group.level;
|
|
419
418
|
groupHeader.headerContent = group.generator(group.key, group.rows.length, group.rows, group);
|
|
420
419
|
groupHeader.rowCount = group.getRows().length;
|
|
421
|
-
|
|
420
|
+
|
|
422
421
|
groupListData.push(groupHeader);
|
|
423
|
-
|
|
422
|
+
|
|
424
423
|
group.getRows().forEach((row) => {
|
|
425
424
|
groupListData.push(row.getData("data"));
|
|
426
425
|
});
|
|
427
426
|
}
|
|
428
427
|
});
|
|
429
|
-
|
|
428
|
+
|
|
430
429
|
return groupListData;
|
|
431
430
|
}
|
|
432
|
-
|
|
431
|
+
|
|
433
432
|
getGroupedData(){
|
|
434
|
-
|
|
433
|
+
|
|
435
434
|
return this.pullGroupListData(this.groupList);
|
|
436
435
|
}
|
|
437
|
-
|
|
436
|
+
|
|
438
437
|
getRowGroup(row){
|
|
439
438
|
var match = false;
|
|
440
|
-
|
|
439
|
+
|
|
441
440
|
if(this.options("dataTree")){
|
|
442
441
|
row = this.table.modules.dataTree.getTreeParentRoot(row);
|
|
443
442
|
}
|
|
444
|
-
|
|
443
|
+
|
|
445
444
|
this.groupList.forEach((group) => {
|
|
446
445
|
var result = group.getRowGroup(row);
|
|
447
|
-
|
|
446
|
+
|
|
448
447
|
if(result){
|
|
449
448
|
match = result;
|
|
450
449
|
}
|
|
451
450
|
});
|
|
452
|
-
|
|
451
|
+
|
|
453
452
|
return match;
|
|
454
453
|
}
|
|
455
|
-
|
|
454
|
+
|
|
456
455
|
countGroups(){
|
|
457
456
|
return this.groupList.length;
|
|
458
457
|
}
|
|
459
|
-
|
|
458
|
+
|
|
460
459
|
generateGroups(rows){
|
|
461
460
|
var oldGroups = this.groups;
|
|
462
|
-
|
|
461
|
+
|
|
463
462
|
this.groups = {};
|
|
464
463
|
this.groupList = [];
|
|
465
|
-
|
|
464
|
+
|
|
466
465
|
if(this.allowedValues && this.allowedValues[0]){
|
|
467
466
|
this.allowedValues[0].forEach((value) => {
|
|
468
467
|
this.createGroup(value, 0, oldGroups);
|
|
469
468
|
});
|
|
470
|
-
|
|
469
|
+
|
|
471
470
|
rows.forEach((row) => {
|
|
472
471
|
this.assignRowToExistingGroup(row, oldGroups);
|
|
473
472
|
});
|
|
@@ -477,53 +476,53 @@ class GroupRows extends Module{
|
|
|
477
476
|
});
|
|
478
477
|
}
|
|
479
478
|
}
|
|
480
|
-
|
|
479
|
+
|
|
481
480
|
createGroup(groupID, level, oldGroups){
|
|
482
481
|
var groupKey = level + "_" + groupID,
|
|
483
482
|
group;
|
|
484
|
-
|
|
483
|
+
|
|
485
484
|
oldGroups = oldGroups || [];
|
|
486
|
-
|
|
485
|
+
|
|
487
486
|
group = new Group(this, false, level, groupID, this.groupIDLookups[0].field, this.headerGenerator[0], oldGroups[groupKey]);
|
|
488
|
-
|
|
487
|
+
|
|
489
488
|
this.groups[groupKey] = group;
|
|
490
489
|
this.groupList.push(group);
|
|
491
490
|
}
|
|
492
|
-
|
|
491
|
+
|
|
493
492
|
assignRowToExistingGroup(row, oldGroups){
|
|
494
493
|
var groupID = this.groupIDLookups[0].func(row.getData()),
|
|
495
494
|
groupKey = "0_" + groupID;
|
|
496
|
-
|
|
495
|
+
|
|
497
496
|
if(this.groups[groupKey]){
|
|
498
497
|
this.groups[groupKey].addRow(row);
|
|
499
498
|
}
|
|
500
499
|
}
|
|
501
|
-
|
|
500
|
+
|
|
502
501
|
assignRowToGroup(row, oldGroups){
|
|
503
502
|
var groupID = this.groupIDLookups[0].func(row.getData()),
|
|
504
503
|
newGroupNeeded = !this.groups["0_" + groupID];
|
|
505
|
-
|
|
504
|
+
|
|
506
505
|
if(newGroupNeeded){
|
|
507
506
|
this.createGroup(groupID, 0, oldGroups);
|
|
508
507
|
}
|
|
509
|
-
|
|
508
|
+
|
|
510
509
|
this.groups["0_" + groupID].addRow(row);
|
|
511
|
-
|
|
510
|
+
|
|
512
511
|
return !newGroupNeeded;
|
|
513
512
|
}
|
|
514
|
-
|
|
513
|
+
|
|
515
514
|
reassignRowToGroup(row){
|
|
516
515
|
if(row.type === "row"){
|
|
517
516
|
var oldRowGroup = row.modules.group,
|
|
518
517
|
oldGroupPath = oldRowGroup.getPath(),
|
|
519
518
|
newGroupPath = this.getExpectedPath(row),
|
|
520
519
|
samePath;
|
|
521
|
-
|
|
520
|
+
|
|
522
521
|
// figure out if new group path is the same as old group path
|
|
523
522
|
samePath = (oldGroupPath.length == newGroupPath.length) && oldGroupPath.every((element, index) => {
|
|
524
523
|
return element === newGroupPath[index];
|
|
525
524
|
});
|
|
526
|
-
|
|
525
|
+
|
|
527
526
|
// refresh if they new path and old path aren't the same (aka the row's groupings have changed)
|
|
528
527
|
if(!samePath) {
|
|
529
528
|
oldRowGroup.removeRow(row);
|
|
@@ -532,57 +531,81 @@ class GroupRows extends Module{
|
|
|
532
531
|
}
|
|
533
532
|
}
|
|
534
533
|
}
|
|
535
|
-
|
|
534
|
+
|
|
536
535
|
getExpectedPath(row) {
|
|
537
536
|
var groupPath = [], rowData = row.getData();
|
|
538
|
-
|
|
537
|
+
|
|
539
538
|
this.groupIDLookups.forEach((groupId) => {
|
|
540
539
|
groupPath.push(groupId.func(rowData));
|
|
541
540
|
});
|
|
542
|
-
|
|
541
|
+
|
|
543
542
|
return groupPath;
|
|
544
543
|
}
|
|
545
|
-
|
|
544
|
+
|
|
546
545
|
updateGroupRows(force){
|
|
547
546
|
var output = [];
|
|
548
|
-
|
|
547
|
+
|
|
549
548
|
this.groupList.forEach((group) => {
|
|
550
549
|
output = output.concat(group.getHeadersAndRows());
|
|
551
550
|
});
|
|
552
|
-
|
|
551
|
+
|
|
553
552
|
if(force){
|
|
554
553
|
this.refreshData(true, this.displayHandler);
|
|
555
554
|
}
|
|
556
|
-
|
|
555
|
+
|
|
557
556
|
return output;
|
|
558
557
|
}
|
|
559
|
-
|
|
558
|
+
|
|
560
559
|
scrollHeaders(left){
|
|
561
|
-
if(this.table.options.
|
|
562
|
-
|
|
560
|
+
if(this.table.options.groupBy){
|
|
561
|
+
if(this.table.options.renderHorizontal === "virtual"){
|
|
562
|
+
left -= this.table.columnManager.renderer.vDomPadLeft;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
left = left + "px";
|
|
566
|
+
|
|
567
|
+
this.groupList.forEach((group) => {
|
|
568
|
+
group.scrollHeader(left);
|
|
569
|
+
});
|
|
563
570
|
}
|
|
564
|
-
|
|
565
|
-
left = left + "px";
|
|
566
|
-
|
|
567
|
-
this.groupList.forEach((group) => {
|
|
568
|
-
group.scrollHeader(left);
|
|
569
|
-
});
|
|
570
571
|
}
|
|
571
|
-
|
|
572
|
+
|
|
572
573
|
removeGroup(group){
|
|
573
574
|
var groupKey = group.level + "_" + group.key,
|
|
574
575
|
index;
|
|
575
|
-
|
|
576
|
+
|
|
576
577
|
if(this.groups[groupKey]){
|
|
577
578
|
delete this.groups[groupKey];
|
|
578
|
-
|
|
579
|
+
|
|
579
580
|
index = this.groupList.indexOf(group);
|
|
580
|
-
|
|
581
|
+
|
|
581
582
|
if(index > -1){
|
|
582
583
|
this.groupList.splice(index, 1);
|
|
583
584
|
}
|
|
584
585
|
}
|
|
585
586
|
}
|
|
587
|
+
|
|
588
|
+
checkBasicModeGroupHeaderWidth(){
|
|
589
|
+
var element = this.table.rowManager.tableElement,
|
|
590
|
+
onlyGroupHeaders = true;
|
|
591
|
+
|
|
592
|
+
this.table.rowManager.getDisplayRows().forEach((row, index) =>{
|
|
593
|
+
this.table.rowManager.styleRow(row, index);
|
|
594
|
+
element.appendChild(row.getElement());
|
|
595
|
+
row.initialize(true);
|
|
596
|
+
|
|
597
|
+
if(row.type !== "group"){
|
|
598
|
+
onlyGroupHeaders = false;
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
if(onlyGroupHeaders){
|
|
603
|
+
element.style.minWidth = this.table.columnManager.getWidth() + "px";
|
|
604
|
+
}else{
|
|
605
|
+
element.style.minWidth = "";
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
586
609
|
}
|
|
587
610
|
|
|
588
611
|
GroupRows.moduleName = "groupRows";
|