tabulator-tables 5.3.3 → 5.4.0
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/build/Bundler.js +64 -38
- package/dist/css/tabulator.css +69 -19
- package/dist/css/tabulator.css.map +1 -1
- package/dist/css/tabulator.min.css +1 -1
- package/dist/css/tabulator.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap3.css +69 -19
- 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 +69 -19
- 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 +69 -19
- 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/css/tabulator_bulma.css +69 -19
- package/dist/css/tabulator_bulma.css.map +1 -1
- package/dist/css/tabulator_bulma.min.css +1 -1
- package/dist/css/tabulator_bulma.min.css.map +1 -1
- package/dist/css/tabulator_materialize.css +69 -19
- package/dist/css/tabulator_materialize.css.map +1 -1
- package/dist/css/tabulator_materialize.min.css +1 -1
- package/dist/css/tabulator_materialize.min.css.map +1 -1
- package/dist/css/tabulator_midnight.css +69 -19
- package/dist/css/tabulator_midnight.css.map +1 -1
- package/dist/css/tabulator_midnight.min.css +1 -1
- package/dist/css/tabulator_midnight.min.css.map +1 -1
- package/dist/css/tabulator_modern.css +69 -19
- package/dist/css/tabulator_modern.css.map +1 -1
- package/dist/css/tabulator_modern.min.css +1 -1
- package/dist/css/tabulator_modern.min.css.map +1 -1
- package/dist/css/tabulator_semanticui.css +69 -19
- package/dist/css/tabulator_semanticui.css.map +1 -1
- package/dist/css/tabulator_semanticui.min.css +1 -1
- package/dist/css/tabulator_semanticui.min.css.map +1 -1
- package/dist/css/tabulator_simple.css +69 -19
- package/dist/css/tabulator_simple.css.map +1 -1
- package/dist/css/tabulator_simple.min.css +1 -1
- package/dist/css/tabulator_simple.min.css.map +1 -1
- package/dist/css/tabulator_site.css +69 -19
- package/dist/css/tabulator_site.css.map +1 -1
- package/dist/css/tabulator_site.min.css +1 -1
- package/dist/css/tabulator_site.min.css.map +1 -1
- package/dist/js/tabulator.js +25819 -27493
- 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 +706 -508
- 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 +3 -6
- package/src/js/core/ColumnManager.js +32 -17
- package/src/js/core/RowManager.js +30 -4
- package/src/js/core/column/Column.js +4 -0
- package/src/js/core/column/defaults/options.js +1 -0
- package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +76 -77
- package/src/js/core/row/Row.js +1 -1
- package/src/js/core/tools/InteractionMonitor.js +2 -0
- package/src/js/core/tools/Popup.js +98 -76
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +185 -146
- package/src/js/modules/Download/defaults/downloaders/xlsx.js +2 -1
- package/src/js/modules/Edit/Edit.js +13 -2
- package/src/js/modules/Format/Format.js +46 -40
- package/src/js/modules/Format/defaults/formatters/responsiveCollapse.js +9 -1
- package/src/js/modules/FrozenColumns/FrozenColumns.js +24 -57
- package/src/js/modules/FrozenRows/FrozenRows.js +4 -3
- package/src/js/modules/GroupRows/Group.js +20 -28
- package/src/js/modules/GroupRows/GroupComponent.js +1 -1
- package/src/js/modules/GroupRows/GroupRows.js +1 -2
- package/src/js/modules/Interaction/Interaction.js +12 -0
- package/src/js/modules/Menu/Menu.js +31 -7
- package/src/js/modules/MoveColumns/MoveColumns.js +3 -3
- package/src/js/modules/Persistence/Persistence.js +1 -0
- package/src/js/modules/Popup/Popup.js +42 -4
- package/src/js/modules/ResizeColumns/ResizeColumns.js +25 -6
- package/src/js/modules/ResizeTable/ResizeTable.js +7 -8
- package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +21 -21
- package/src/js/modules/Sort/Sort.js +14 -2
- package/src/scss/tabulator.scss +92 -31
|
@@ -9,10 +9,10 @@ import Row from '../../core/row/Row.js';
|
|
|
9
9
|
import defaultCalculations from './defaults/calculations.js';
|
|
10
10
|
|
|
11
11
|
class ColumnCalcs extends Module{
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
constructor(table){
|
|
14
14
|
super(table);
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
this.topCalcs = [];
|
|
17
17
|
this.botCalcs = [];
|
|
18
18
|
this.genColumn = false;
|
|
@@ -22,9 +22,12 @@ class ColumnCalcs extends Module{
|
|
|
22
22
|
this.botRow = false;
|
|
23
23
|
this.topInitialized = false;
|
|
24
24
|
this.botInitialized = false;
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
this.blocked = false;
|
|
27
|
+
this.recalcAfterBlock = false;
|
|
28
|
+
|
|
26
29
|
this.registerTableOption("columnCalcs", true);
|
|
27
|
-
|
|
30
|
+
|
|
28
31
|
this.registerColumnOption("topCalc");
|
|
29
32
|
this.registerColumnOption("topCalcParams");
|
|
30
33
|
this.registerColumnOption("topCalcFormatter");
|
|
@@ -34,16 +37,16 @@ class ColumnCalcs extends Module{
|
|
|
34
37
|
this.registerColumnOption("bottomCalcFormatter");
|
|
35
38
|
this.registerColumnOption("bottomCalcFormatterParams");
|
|
36
39
|
}
|
|
37
|
-
|
|
40
|
+
|
|
38
41
|
createElement (){
|
|
39
42
|
var el = document.createElement("div");
|
|
40
43
|
el.classList.add("tabulator-calcs-holder");
|
|
41
44
|
return el;
|
|
42
45
|
}
|
|
43
|
-
|
|
46
|
+
|
|
44
47
|
initialize(){
|
|
45
48
|
this.genColumn = new Column({field:"value"}, this);
|
|
46
|
-
|
|
49
|
+
|
|
47
50
|
this.subscribe("cell-value-changed", this.cellValueChanged.bind(this));
|
|
48
51
|
this.subscribe("column-init", this.initializeColumnCheck.bind(this));
|
|
49
52
|
this.subscribe("row-deleted", this.rowsUpdated.bind(this));
|
|
@@ -54,43 +57,69 @@ class ColumnCalcs extends Module{
|
|
|
54
57
|
this.subscribe("data-refreshed", this.recalcActiveRowsRefresh.bind(this));
|
|
55
58
|
this.subscribe("table-redraw", this.tableRedraw.bind(this));
|
|
56
59
|
this.subscribe("rows-visible", this.visibleRows.bind(this));
|
|
57
|
-
|
|
60
|
+
this.subscribe("scrollbar-vertical", this.adjustForScrollbar.bind(this));
|
|
61
|
+
|
|
62
|
+
this.subscribe("redraw-blocked", this.blockRedraw.bind(this));
|
|
63
|
+
this.subscribe("redraw-restored", this.restoreRedraw.bind(this));
|
|
64
|
+
|
|
58
65
|
this.registerTableFunction("getCalcResults", this.getResults.bind(this));
|
|
59
66
|
this.registerTableFunction("recalc", this.userRecalc.bind(this));
|
|
60
67
|
}
|
|
61
|
-
|
|
68
|
+
|
|
62
69
|
tableRedraw(force){
|
|
63
70
|
this.recalc(this.table.rowManager.activeRows);
|
|
64
|
-
|
|
71
|
+
|
|
65
72
|
if(force){
|
|
66
73
|
this.redraw();
|
|
67
74
|
}
|
|
68
75
|
}
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
|
|
77
|
+
blockRedraw(){
|
|
78
|
+
this.blocked = true;
|
|
79
|
+
this.recalcAfterBlock = false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
restoreRedraw(){
|
|
84
|
+
this.blocked = false;
|
|
85
|
+
|
|
86
|
+
if(this.recalcAfterBlock){
|
|
87
|
+
this.recalcAfterBlock = false;
|
|
88
|
+
this.recalcActiveRowsRefresh();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
71
92
|
///////////////////////////////////
|
|
72
93
|
///////// Table Functions /////////
|
|
73
94
|
///////////////////////////////////
|
|
74
95
|
userRecalc(){
|
|
75
96
|
this.recalc(this.table.rowManager.activeRows);
|
|
76
97
|
}
|
|
77
|
-
|
|
98
|
+
|
|
78
99
|
///////////////////////////////////
|
|
79
100
|
///////// Internal Logic //////////
|
|
80
101
|
///////////////////////////////////
|
|
81
|
-
|
|
102
|
+
|
|
103
|
+
blockCheck(){
|
|
104
|
+
if(this.blocked){
|
|
105
|
+
this.recalcAfterBlock = true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return this.blocked;
|
|
109
|
+
}
|
|
110
|
+
|
|
82
111
|
visibleRows(viewable, rows){
|
|
83
112
|
if(this.topRow){
|
|
84
113
|
rows.unshift(this.topRow);
|
|
85
114
|
}
|
|
86
|
-
|
|
115
|
+
|
|
87
116
|
if(this.botRow){
|
|
88
117
|
rows.push(this.botRow);
|
|
89
118
|
}
|
|
90
|
-
|
|
119
|
+
|
|
91
120
|
return rows;
|
|
92
121
|
}
|
|
93
|
-
|
|
122
|
+
|
|
94
123
|
rowsUpdated(row){
|
|
95
124
|
if(this.table.options.groupBy){
|
|
96
125
|
this.recalcRowGroup(row);
|
|
@@ -98,7 +127,7 @@ class ColumnCalcs extends Module{
|
|
|
98
127
|
this.recalcActiveRows();
|
|
99
128
|
}
|
|
100
129
|
}
|
|
101
|
-
|
|
130
|
+
|
|
102
131
|
recalcActiveRowsRefresh(){
|
|
103
132
|
if(this.table.options.groupBy && this.table.options.dataTreeStartExpanded && this.table.options.dataTree){
|
|
104
133
|
this.recalcAll();
|
|
@@ -106,18 +135,18 @@ class ColumnCalcs extends Module{
|
|
|
106
135
|
this.recalcActiveRows();
|
|
107
136
|
}
|
|
108
137
|
}
|
|
109
|
-
|
|
138
|
+
|
|
110
139
|
recalcActiveRows(){
|
|
111
140
|
this.recalc(this.table.rowManager.activeRows);
|
|
112
141
|
}
|
|
113
|
-
|
|
142
|
+
|
|
114
143
|
cellValueChanged(cell){
|
|
115
144
|
if(cell.column.definition.topCalc || cell.column.definition.bottomCalc){
|
|
116
145
|
if(this.table.options.groupBy){
|
|
117
146
|
if(this.table.options.columnCalcs == "table" || this.table.options.columnCalcs == "both"){
|
|
118
147
|
this.recalcActiveRows();
|
|
119
148
|
}
|
|
120
|
-
|
|
149
|
+
|
|
121
150
|
if(this.table.options.columnCalcs != "table"){
|
|
122
151
|
this.recalcRowGroup(cell.row);
|
|
123
152
|
}
|
|
@@ -126,24 +155,24 @@ class ColumnCalcs extends Module{
|
|
|
126
155
|
}
|
|
127
156
|
}
|
|
128
157
|
}
|
|
129
|
-
|
|
158
|
+
|
|
130
159
|
initializeColumnCheck(column){
|
|
131
160
|
if(column.definition.topCalc || column.definition.bottomCalc){
|
|
132
161
|
this.initializeColumn(column);
|
|
133
162
|
}
|
|
134
163
|
}
|
|
135
|
-
|
|
164
|
+
|
|
136
165
|
//initialize column calcs
|
|
137
166
|
initializeColumn(column){
|
|
138
167
|
var def = column.definition;
|
|
139
|
-
|
|
168
|
+
|
|
140
169
|
var config = {
|
|
141
170
|
topCalcParams:def.topCalcParams || {},
|
|
142
171
|
botCalcParams:def.bottomCalcParams || {},
|
|
143
172
|
};
|
|
144
|
-
|
|
173
|
+
|
|
145
174
|
if(def.topCalc){
|
|
146
|
-
|
|
175
|
+
|
|
147
176
|
switch(typeof def.topCalc){
|
|
148
177
|
case "string":
|
|
149
178
|
if(ColumnCalcs.calculations[def.topCalc]){
|
|
@@ -152,24 +181,24 @@ class ColumnCalcs extends Module{
|
|
|
152
181
|
console.warn("Column Calc Error - No such calculation found, ignoring: ", def.topCalc);
|
|
153
182
|
}
|
|
154
183
|
break;
|
|
155
|
-
|
|
184
|
+
|
|
156
185
|
case "function":
|
|
157
186
|
config.topCalc = def.topCalc;
|
|
158
187
|
break;
|
|
159
|
-
|
|
188
|
+
|
|
160
189
|
}
|
|
161
|
-
|
|
190
|
+
|
|
162
191
|
if(config.topCalc){
|
|
163
192
|
column.modules.columnCalcs = config;
|
|
164
193
|
this.topCalcs.push(column);
|
|
165
|
-
|
|
194
|
+
|
|
166
195
|
if(this.table.options.columnCalcs != "group"){
|
|
167
196
|
this.initializeTopRow();
|
|
168
197
|
}
|
|
169
198
|
}
|
|
170
|
-
|
|
199
|
+
|
|
171
200
|
}
|
|
172
|
-
|
|
201
|
+
|
|
173
202
|
if(def.bottomCalc){
|
|
174
203
|
switch(typeof def.bottomCalc){
|
|
175
204
|
case "string":
|
|
@@ -179,156 +208,156 @@ class ColumnCalcs extends Module{
|
|
|
179
208
|
console.warn("Column Calc Error - No such calculation found, ignoring: ", def.bottomCalc);
|
|
180
209
|
}
|
|
181
210
|
break;
|
|
182
|
-
|
|
211
|
+
|
|
183
212
|
case "function":
|
|
184
213
|
config.botCalc = def.bottomCalc;
|
|
185
214
|
break;
|
|
186
|
-
|
|
215
|
+
|
|
187
216
|
}
|
|
188
|
-
|
|
217
|
+
|
|
189
218
|
if(config.botCalc){
|
|
190
219
|
column.modules.columnCalcs = config;
|
|
191
220
|
this.botCalcs.push(column);
|
|
192
|
-
|
|
221
|
+
|
|
193
222
|
if(this.table.options.columnCalcs != "group"){
|
|
194
223
|
this.initializeBottomRow();
|
|
195
224
|
}
|
|
196
225
|
}
|
|
197
226
|
}
|
|
198
|
-
|
|
227
|
+
|
|
199
228
|
}
|
|
200
|
-
|
|
229
|
+
|
|
201
230
|
//dummy functions to handle being mock column manager
|
|
202
231
|
registerColumnField(){}
|
|
203
|
-
|
|
232
|
+
|
|
204
233
|
removeCalcs(){
|
|
205
234
|
var changed = false;
|
|
206
|
-
|
|
235
|
+
|
|
207
236
|
if(this.topInitialized){
|
|
208
237
|
this.topInitialized = false;
|
|
209
238
|
this.topElement.parentNode.removeChild(this.topElement);
|
|
210
239
|
changed = true;
|
|
211
240
|
}
|
|
212
|
-
|
|
241
|
+
|
|
213
242
|
if(this.botInitialized){
|
|
214
243
|
this.botInitialized = false;
|
|
215
244
|
this.footerRemove(this.botElement);
|
|
216
245
|
changed = true;
|
|
217
246
|
}
|
|
218
|
-
|
|
247
|
+
|
|
219
248
|
if(changed){
|
|
220
249
|
this.table.rowManager.adjustTableSize();
|
|
221
250
|
}
|
|
222
251
|
}
|
|
223
|
-
|
|
252
|
+
|
|
224
253
|
initializeTopRow(){
|
|
225
254
|
if(!this.topInitialized){
|
|
226
|
-
this.table.columnManager.
|
|
255
|
+
this.table.columnManager.getContentsElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling);
|
|
227
256
|
this.topInitialized = true;
|
|
228
257
|
}
|
|
229
258
|
}
|
|
230
|
-
|
|
259
|
+
|
|
231
260
|
initializeBottomRow(){
|
|
232
261
|
if(!this.botInitialized){
|
|
233
262
|
this.footerPrepend(this.botElement);
|
|
234
263
|
this.botInitialized = true;
|
|
235
264
|
}
|
|
236
265
|
}
|
|
237
|
-
|
|
266
|
+
|
|
238
267
|
scrollHorizontal(left){
|
|
239
268
|
if(this.botInitialized && this.botRow){
|
|
240
|
-
|
|
241
|
-
this.botRow.getElement().style.marginRight = (left) + "px";
|
|
242
|
-
}else{
|
|
243
|
-
this.botRow.getElement().style.marginLeft = (-left) + "px";
|
|
244
|
-
}
|
|
269
|
+
this.botElement.scrollLeft = left;
|
|
245
270
|
}
|
|
246
271
|
}
|
|
247
|
-
|
|
272
|
+
|
|
248
273
|
recalc(rows){
|
|
249
274
|
var data, row;
|
|
250
|
-
|
|
251
|
-
if(this.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if(this.
|
|
256
|
-
this.topRow
|
|
275
|
+
|
|
276
|
+
if(!this.blockCheck()){
|
|
277
|
+
if(this.topInitialized || this.botInitialized){
|
|
278
|
+
data = this.rowsToData(rows);
|
|
279
|
+
|
|
280
|
+
if(this.topInitialized){
|
|
281
|
+
if(this.topRow){
|
|
282
|
+
this.topRow.deleteCells();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
row = this.generateRow("top", data);
|
|
286
|
+
this.topRow = row;
|
|
287
|
+
while(this.topElement.firstChild) this.topElement.removeChild(this.topElement.firstChild);
|
|
288
|
+
this.topElement.appendChild(row.getElement());
|
|
289
|
+
row.initialize(true);
|
|
257
290
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
291
|
+
|
|
292
|
+
if(this.botInitialized){
|
|
293
|
+
if(this.botRow){
|
|
294
|
+
this.botRow.deleteCells();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
row = this.generateRow("bottom", data);
|
|
298
|
+
this.botRow = row;
|
|
299
|
+
while(this.botElement.firstChild) this.botElement.removeChild(this.botElement.firstChild);
|
|
300
|
+
this.botElement.appendChild(row.getElement());
|
|
301
|
+
row.initialize(true);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
this.table.rowManager.adjustTableSize();
|
|
305
|
+
|
|
306
|
+
//set resizable handles
|
|
307
|
+
if(this.table.modExists("frozenColumns")){
|
|
308
|
+
this.table.modules.frozenColumns.layout();
|
|
269
309
|
}
|
|
270
|
-
|
|
271
|
-
row = this.generateRow("bottom", data);
|
|
272
|
-
this.botRow = row;
|
|
273
|
-
while(this.botElement.firstChild) this.botElement.removeChild(this.botElement.firstChild);
|
|
274
|
-
this.botElement.appendChild(row.getElement());
|
|
275
|
-
row.initialize(true);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
this.table.rowManager.adjustTableSize();
|
|
279
|
-
|
|
280
|
-
//set resizable handles
|
|
281
|
-
if(this.table.modExists("frozenColumns")){
|
|
282
|
-
this.table.modules.frozenColumns.layout();
|
|
283
310
|
}
|
|
284
311
|
}
|
|
285
312
|
}
|
|
286
|
-
|
|
313
|
+
|
|
287
314
|
recalcRowGroup(row){
|
|
288
315
|
this.recalcGroup(this.table.modules.groupRows.getRowGroup(row));
|
|
289
316
|
}
|
|
290
|
-
|
|
317
|
+
|
|
291
318
|
recalcAll(){
|
|
292
319
|
if(this.topCalcs.length || this.botCalcs.length){
|
|
293
320
|
if(this.table.options.columnCalcs !== "group"){
|
|
294
321
|
this.recalcActiveRows();
|
|
295
322
|
}
|
|
296
|
-
|
|
323
|
+
|
|
297
324
|
if(this.table.options.groupBy && this.table.options.columnCalcs !== "table"){
|
|
298
|
-
|
|
325
|
+
|
|
299
326
|
var groups = this.table.modules.groupRows.getChildGroups();
|
|
300
|
-
|
|
327
|
+
|
|
301
328
|
groups.forEach((group) => {
|
|
302
329
|
this.recalcGroup(group);
|
|
303
330
|
});
|
|
304
331
|
}
|
|
305
332
|
}
|
|
306
333
|
}
|
|
307
|
-
|
|
334
|
+
|
|
308
335
|
recalcGroup(group){
|
|
309
336
|
var data, rowData;
|
|
310
|
-
|
|
311
|
-
if(
|
|
312
|
-
if(group
|
|
313
|
-
if(group.calcs
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
337
|
+
|
|
338
|
+
if(!this.blockCheck()){
|
|
339
|
+
if(group){
|
|
340
|
+
if(group.calcs){
|
|
341
|
+
if(group.calcs.bottom){
|
|
342
|
+
data = this.rowsToData(group.rows);
|
|
343
|
+
rowData = this.generateRowData("bottom", data);
|
|
344
|
+
|
|
345
|
+
group.calcs.bottom.updateData(rowData);
|
|
346
|
+
group.calcs.bottom.reinitialize();
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if(group.calcs.top){
|
|
350
|
+
data = this.rowsToData(group.rows);
|
|
351
|
+
rowData = this.generateRowData("top", data);
|
|
352
|
+
|
|
353
|
+
group.calcs.top.updateData(rowData);
|
|
354
|
+
group.calcs.top.reinitialize();
|
|
355
|
+
}
|
|
327
356
|
}
|
|
328
357
|
}
|
|
329
358
|
}
|
|
330
359
|
}
|
|
331
|
-
|
|
360
|
+
|
|
332
361
|
//generate top stats row
|
|
333
362
|
generateTopRow(rows){
|
|
334
363
|
return this.generateRow("top", this.rowsToData(rows));
|
|
@@ -337,13 +366,13 @@ class ColumnCalcs extends Module{
|
|
|
337
366
|
generateBottomRow(rows){
|
|
338
367
|
return this.generateRow("bottom", this.rowsToData(rows));
|
|
339
368
|
}
|
|
340
|
-
|
|
369
|
+
|
|
341
370
|
rowsToData(rows){
|
|
342
371
|
var data = [];
|
|
343
372
|
|
|
344
373
|
rows.forEach((row) => {
|
|
345
374
|
data.push(row.getData());
|
|
346
|
-
|
|
375
|
+
|
|
347
376
|
if(this.table.options.dataTree && this.table.options.dataTreeChildColumnCalcs){
|
|
348
377
|
if(row.modules.dataTree && row.modules.dataTree.open){
|
|
349
378
|
var children = this.rowsToData(this.table.modules.dataTree.getFilteredTreeChildren(row));
|
|
@@ -351,47 +380,47 @@ class ColumnCalcs extends Module{
|
|
|
351
380
|
}
|
|
352
381
|
}
|
|
353
382
|
});
|
|
354
|
-
|
|
383
|
+
|
|
355
384
|
return data;
|
|
356
385
|
}
|
|
357
|
-
|
|
386
|
+
|
|
358
387
|
//generate stats row
|
|
359
388
|
generateRow(pos, data){
|
|
360
389
|
var rowData = this.generateRowData(pos, data),
|
|
361
390
|
row;
|
|
362
|
-
|
|
391
|
+
|
|
363
392
|
if(this.table.modExists("mutator")){
|
|
364
393
|
this.table.modules.mutator.disable();
|
|
365
394
|
}
|
|
366
|
-
|
|
395
|
+
|
|
367
396
|
row = new Row(rowData, this, "calc");
|
|
368
|
-
|
|
397
|
+
|
|
369
398
|
if(this.table.modExists("mutator")){
|
|
370
399
|
this.table.modules.mutator.enable();
|
|
371
400
|
}
|
|
372
|
-
|
|
401
|
+
|
|
373
402
|
row.getElement().classList.add("tabulator-calcs", "tabulator-calcs-" + pos);
|
|
374
|
-
|
|
403
|
+
|
|
375
404
|
row.component = false;
|
|
376
|
-
|
|
405
|
+
|
|
377
406
|
row.getComponent = () => {
|
|
378
407
|
if(!row.component){
|
|
379
408
|
row.component = new CalcComponent(row);
|
|
380
409
|
}
|
|
381
|
-
|
|
410
|
+
|
|
382
411
|
return row.component;
|
|
383
412
|
};
|
|
384
|
-
|
|
413
|
+
|
|
385
414
|
row.generateCells = () => {
|
|
386
|
-
|
|
415
|
+
|
|
387
416
|
var cells = [];
|
|
388
|
-
|
|
417
|
+
|
|
389
418
|
this.table.columnManager.columnsByIndex.forEach((column) => {
|
|
390
|
-
|
|
419
|
+
|
|
391
420
|
//set field name of mock column
|
|
392
421
|
this.genColumn.setField(column.getField());
|
|
393
422
|
this.genColumn.hozAlign = column.hozAlign;
|
|
394
|
-
|
|
423
|
+
|
|
395
424
|
if(column.definition[pos + "CalcFormatter"] && this.table.modExists("format")){
|
|
396
425
|
this.genColumn.modules.format = {
|
|
397
426
|
formatter: this.table.modules.format.getFormatter(column.definition[pos + "CalcFormatter"]),
|
|
@@ -403,63 +432,63 @@ class ColumnCalcs extends Module{
|
|
|
403
432
|
params:{}
|
|
404
433
|
};
|
|
405
434
|
}
|
|
406
|
-
|
|
435
|
+
|
|
407
436
|
//ensure css class definition is replicated to calculation cell
|
|
408
437
|
this.genColumn.definition.cssClass = column.definition.cssClass;
|
|
409
|
-
|
|
438
|
+
|
|
410
439
|
//generate cell and assign to correct column
|
|
411
440
|
var cell = new Cell(this.genColumn, row);
|
|
412
441
|
cell.getElement();
|
|
413
442
|
cell.column = column;
|
|
414
443
|
cell.setWidth();
|
|
415
|
-
|
|
444
|
+
|
|
416
445
|
column.cells.push(cell);
|
|
417
446
|
cells.push(cell);
|
|
418
|
-
|
|
447
|
+
|
|
419
448
|
if(!column.visible){
|
|
420
449
|
cell.hide();
|
|
421
450
|
}
|
|
422
451
|
});
|
|
423
|
-
|
|
452
|
+
|
|
424
453
|
row.cells = cells;
|
|
425
454
|
};
|
|
426
|
-
|
|
455
|
+
|
|
427
456
|
return row;
|
|
428
457
|
}
|
|
429
|
-
|
|
458
|
+
|
|
430
459
|
//generate stats row
|
|
431
460
|
generateRowData(pos, data){
|
|
432
461
|
var rowData = {},
|
|
433
462
|
calcs = pos == "top" ? this.topCalcs : this.botCalcs,
|
|
434
463
|
type = pos == "top" ? "topCalc" : "botCalc",
|
|
435
464
|
params, paramKey;
|
|
436
|
-
|
|
465
|
+
|
|
437
466
|
calcs.forEach(function(column){
|
|
438
467
|
var values = [];
|
|
439
|
-
|
|
468
|
+
|
|
440
469
|
if(column.modules.columnCalcs && column.modules.columnCalcs[type]){
|
|
441
470
|
data.forEach(function(item){
|
|
442
471
|
values.push(column.getFieldValue(item));
|
|
443
472
|
});
|
|
444
|
-
|
|
473
|
+
|
|
445
474
|
paramKey = type + "Params";
|
|
446
475
|
params = typeof column.modules.columnCalcs[paramKey] === "function" ? column.modules.columnCalcs[paramKey](values, data) : column.modules.columnCalcs[paramKey];
|
|
447
|
-
|
|
476
|
+
|
|
448
477
|
column.setFieldValue(rowData, column.modules.columnCalcs[type](values, data, params));
|
|
449
478
|
}
|
|
450
479
|
});
|
|
451
|
-
|
|
480
|
+
|
|
452
481
|
return rowData;
|
|
453
482
|
}
|
|
454
|
-
|
|
483
|
+
|
|
455
484
|
hasTopCalcs(){
|
|
456
485
|
return !!(this.topCalcs.length);
|
|
457
486
|
}
|
|
458
|
-
|
|
487
|
+
|
|
459
488
|
hasBottomCalcs(){
|
|
460
489
|
return !!(this.botCalcs.length);
|
|
461
490
|
}
|
|
462
|
-
|
|
491
|
+
|
|
463
492
|
//handle table redraw
|
|
464
493
|
redraw(){
|
|
465
494
|
if(this.topRow){
|
|
@@ -469,15 +498,15 @@ class ColumnCalcs extends Module{
|
|
|
469
498
|
this.botRow.normalizeHeight(true);
|
|
470
499
|
}
|
|
471
500
|
}
|
|
472
|
-
|
|
501
|
+
|
|
473
502
|
//return the calculated
|
|
474
503
|
getResults(){
|
|
475
504
|
var results = {},
|
|
476
505
|
groups;
|
|
477
|
-
|
|
506
|
+
|
|
478
507
|
if(this.table.options.groupBy && this.table.modExists("groupRows")){
|
|
479
508
|
groups = this.table.modules.groupRows.getGroups(true);
|
|
480
|
-
|
|
509
|
+
|
|
481
510
|
groups.forEach((group) => {
|
|
482
511
|
results[group.getKey()] = this.getGroupResults(group);
|
|
483
512
|
});
|
|
@@ -487,29 +516,39 @@ class ColumnCalcs extends Module{
|
|
|
487
516
|
bottom: this.botRow ? this.botRow.getData() : {},
|
|
488
517
|
};
|
|
489
518
|
}
|
|
490
|
-
|
|
519
|
+
|
|
491
520
|
return results;
|
|
492
521
|
}
|
|
493
|
-
|
|
522
|
+
|
|
494
523
|
//get results from a group
|
|
495
524
|
getGroupResults(group){
|
|
496
525
|
var groupObj = group._getSelf(),
|
|
497
526
|
subGroups = group.getSubGroups(),
|
|
498
527
|
subGroupResults = {},
|
|
499
528
|
results = {};
|
|
500
|
-
|
|
529
|
+
|
|
501
530
|
subGroups.forEach((subgroup) => {
|
|
502
531
|
subGroupResults[subgroup.getKey()] = this.getGroupResults(subgroup);
|
|
503
532
|
});
|
|
504
|
-
|
|
533
|
+
|
|
505
534
|
results = {
|
|
506
535
|
top: groupObj.calcs.top ? groupObj.calcs.top.getData() : {},
|
|
507
536
|
bottom: groupObj.calcs.bottom ? groupObj.calcs.bottom.getData() : {},
|
|
508
537
|
groups: subGroupResults,
|
|
509
538
|
};
|
|
510
|
-
|
|
539
|
+
|
|
511
540
|
return results;
|
|
512
541
|
}
|
|
542
|
+
|
|
543
|
+
adjustForScrollbar(width){
|
|
544
|
+
if(this.botRow){
|
|
545
|
+
if(this.table.rtl){
|
|
546
|
+
this.botElement.style.paddingLeft = width + "px";
|
|
547
|
+
}else{
|
|
548
|
+
this.botElement.style.paddingRight = width + "px";
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
513
552
|
}
|
|
514
553
|
|
|
515
554
|
ColumnCalcs.moduleName = "columnCalcs";
|
|
@@ -5,6 +5,7 @@ export default function(list, options, setFileContents){
|
|
|
5
5
|
sheetName = options.sheetName || "Sheet1",
|
|
6
6
|
workbook = XLSX.utils.book_new(),
|
|
7
7
|
tableFeatures = new CoreFeature(this),
|
|
8
|
+
compression = 'compress' in options ? options.compress : true,
|
|
8
9
|
output;
|
|
9
10
|
|
|
10
11
|
workbook.SheetNames = [];
|
|
@@ -92,7 +93,7 @@ export default function(list, options, setFileContents){
|
|
|
92
93
|
return buf;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
output = XLSX.write(workbook, {bookType:'xlsx', bookSST:true, type: 'binary'});
|
|
96
|
+
output = XLSX.write(workbook, {bookType:'xlsx', bookSST:true, type: 'binary', compression });
|
|
96
97
|
|
|
97
98
|
setFileContents(s2ab(output), "application/octet-stream");
|
|
98
99
|
}
|