tabulator-tables 5.0.2 → 5.0.7
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/rollup.js +1 -1
- package/dist/css/tabulator_bootstrap3.css +9 -0
- 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 +0 -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_bulma.css +5 -1
- 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_semanticui.css +11 -2
- 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/js/tabulator.js +460 -308
- 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 +426 -297
- 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 +15 -16
- package/src/js/core/RowManager.js +5 -3
- package/src/js/core/Tabulator.js +178 -117
- package/src/js/core/column/Column.js +2 -2
- package/src/js/core/tools/DataLoader.js +1 -1
- package/src/js/core/tools/ExternalEventBus.js +3 -2
- package/src/js/core/tools/Helpers.js +24 -7
- package/src/js/modules/Accessor/Accessor.js +1 -1
- package/src/js/modules/Ajax/defaults/contentTypeFormatters.js +22 -1
- package/src/js/modules/DataTree/DataTree.js +1 -1
- package/src/js/modules/Edit/Edit.js +7 -6
- package/src/js/modules/Edit/defaults/editors/progress.js +2 -2
- package/src/js/modules/Filter/Filter.js +9 -4
- package/src/js/modules/Format/defaults/formatters/money.js +8 -1
- package/src/js/modules/FrozenColumns/FrozenColumns.js +21 -0
- package/src/js/modules/FrozenRows/FrozenRows.js +4 -1
- package/src/js/modules/GroupRows/Group.js +2 -0
- package/src/js/modules/GroupRows/GroupRows.js +40 -35
- package/src/js/modules/History/History.js +3 -1
- package/src/js/modules/History/defaults/redoers.js +1 -0
- package/src/js/modules/History/defaults/undoers.js +1 -0
- package/src/js/modules/HtmlTableImport/HtmlTableImport.js +4 -22
- package/src/js/modules/MoveColumns/MoveColumns.js +6 -4
- package/src/js/modules/Page/Page.js +0 -4
- package/src/js/modules/ReactiveData/ReactiveData.js +28 -27
- package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +5 -1
- package/src/js/modules/SelectRow/SelectRow.js +1 -2
- package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +9 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +0 -4
- package/src/scss/themes/bulma/tabulator_bulma.scss +5 -1
- package/src/scss/themes/semanticui/tabulator_semanticui.scss +12 -7
package/package.json
CHANGED
|
@@ -64,6 +64,7 @@ export default class ColumnManager extends CoreFeature {
|
|
|
64
64
|
var el = document.createElement("div");
|
|
65
65
|
|
|
66
66
|
el.classList.add("tabulator-headers");
|
|
67
|
+
el.setAttribute("role", "row");
|
|
67
68
|
|
|
68
69
|
return el;
|
|
69
70
|
}
|
|
@@ -72,6 +73,7 @@ export default class ColumnManager extends CoreFeature {
|
|
|
72
73
|
var el = document.createElement("div");
|
|
73
74
|
|
|
74
75
|
el.classList.add("tabulator-header");
|
|
76
|
+
el.setAttribute("role", "rowgroup");
|
|
75
77
|
|
|
76
78
|
if(!this.table.options.headerVisible){
|
|
77
79
|
el.classList.add("tabulator-header-hidden");
|
|
@@ -230,9 +232,9 @@ export default class ColumnManager extends CoreFeature {
|
|
|
230
232
|
index = nextToColumn ? this.findColumnIndex(nextToColumn) : nextToColumn;
|
|
231
233
|
|
|
232
234
|
if(nextToColumn && index > -1){
|
|
233
|
-
|
|
234
|
-
var parentIndex = this.columns.indexOf(
|
|
235
|
-
var nextEl =
|
|
235
|
+
var topColumn = nextToColumn.getTopColumn()
|
|
236
|
+
var parentIndex = this.columns.indexOf(topColumn);
|
|
237
|
+
var nextEl = topColumn.getElement();
|
|
236
238
|
|
|
237
239
|
if(before){
|
|
238
240
|
this.columns.splice(parentIndex, 0, column);
|
|
@@ -241,7 +243,6 @@ export default class ColumnManager extends CoreFeature {
|
|
|
241
243
|
this.columns.splice(parentIndex + 1, 0, column);
|
|
242
244
|
nextEl.parentNode.insertBefore(colEl, nextEl.nextSibling);
|
|
243
245
|
}
|
|
244
|
-
|
|
245
246
|
}else{
|
|
246
247
|
if(before){
|
|
247
248
|
this.columns.unshift(column);
|
|
@@ -250,10 +251,10 @@ export default class ColumnManager extends CoreFeature {
|
|
|
250
251
|
this.columns.push(column);
|
|
251
252
|
this.headersElement.appendChild(column.getElement());
|
|
252
253
|
}
|
|
253
|
-
|
|
254
|
-
column.columnRendered();
|
|
255
254
|
}
|
|
256
255
|
|
|
256
|
+
column.columnRendered();
|
|
257
|
+
|
|
257
258
|
return column;
|
|
258
259
|
}
|
|
259
260
|
|
|
@@ -276,7 +277,7 @@ export default class ColumnManager extends CoreFeature {
|
|
|
276
277
|
}
|
|
277
278
|
|
|
278
279
|
//ensure column headers take up the correct amount of space in column groups
|
|
279
|
-
|
|
280
|
+
verticalAlignHeaders(){
|
|
280
281
|
var minHeight = 0;
|
|
281
282
|
|
|
282
283
|
this.columns.forEach((column) => {
|
|
@@ -433,7 +434,7 @@ export default class ColumnManager extends CoreFeature {
|
|
|
433
434
|
to.element.parentNode.insertBefore(to.element, from.element);
|
|
434
435
|
}
|
|
435
436
|
|
|
436
|
-
this.
|
|
437
|
+
this.verticalAlignHeaders();
|
|
437
438
|
|
|
438
439
|
this.table.rowManager.reinitialize();
|
|
439
440
|
}
|
|
@@ -608,13 +609,11 @@ export default class ColumnManager extends CoreFeature {
|
|
|
608
609
|
|
|
609
610
|
this.dispatch("column-add", definition, before, nextToColumn);
|
|
610
611
|
|
|
611
|
-
this.redraw(true);
|
|
612
|
-
|
|
613
612
|
if(this.layoutMode() != "fitColumns"){
|
|
614
613
|
column.reinitializeWidth();
|
|
615
614
|
}
|
|
616
615
|
|
|
617
|
-
this.
|
|
616
|
+
this.redraw(true);
|
|
618
617
|
|
|
619
618
|
this.table.rowManager.reinitialize();
|
|
620
619
|
|
|
@@ -648,18 +647,18 @@ export default class ColumnManager extends CoreFeature {
|
|
|
648
647
|
this.columns.splice(index, 1);
|
|
649
648
|
}
|
|
650
649
|
|
|
651
|
-
this.
|
|
650
|
+
this.verticalAlignHeaders();
|
|
652
651
|
|
|
653
652
|
this.redraw();
|
|
654
653
|
}
|
|
655
654
|
|
|
656
655
|
//redraw columns
|
|
657
656
|
redraw(force){
|
|
658
|
-
if(
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
}
|
|
657
|
+
if(Helpers.elVisible(this.element)){
|
|
658
|
+
this.verticalAlignHeaders();
|
|
659
|
+
}
|
|
662
660
|
|
|
661
|
+
if(force){
|
|
663
662
|
this.table.rowManager.resetScroll();
|
|
664
663
|
this.table.rowManager.reinitialize();
|
|
665
664
|
}
|
|
@@ -49,6 +49,7 @@ export default class RowManager extends CoreFeature{
|
|
|
49
49
|
|
|
50
50
|
el.classList.add("tabulator-tableholder");
|
|
51
51
|
el.setAttribute("tabindex", 0);
|
|
52
|
+
el.setAttribute("role", "rowgroup");
|
|
52
53
|
|
|
53
54
|
return el;
|
|
54
55
|
}
|
|
@@ -57,6 +58,7 @@ export default class RowManager extends CoreFeature{
|
|
|
57
58
|
var el = document.createElement("div");
|
|
58
59
|
|
|
59
60
|
el.classList.add("tabulator-table");
|
|
61
|
+
el.setAttribute("role", "rowgroup");
|
|
60
62
|
|
|
61
63
|
return el;
|
|
62
64
|
}
|
|
@@ -305,7 +307,7 @@ export default class RowManager extends CoreFeature{
|
|
|
305
307
|
this.dispatch("row-added", row, data, pos, index);
|
|
306
308
|
});
|
|
307
309
|
|
|
308
|
-
this.
|
|
310
|
+
this.refreshActiveData(false, false, true);
|
|
309
311
|
|
|
310
312
|
this.regenerateRowNumbers();
|
|
311
313
|
|
|
@@ -853,13 +855,13 @@ export default class RowManager extends CoreFeature{
|
|
|
853
855
|
}
|
|
854
856
|
|
|
855
857
|
renderTable(){
|
|
856
|
-
|
|
857
858
|
this.dispatchExternal("renderStarted");
|
|
858
859
|
|
|
859
860
|
this.element.scrollTop = 0;
|
|
860
861
|
|
|
862
|
+
this._clearTable();
|
|
863
|
+
|
|
861
864
|
if(this.displayRowsCount){
|
|
862
|
-
this._clearTable();
|
|
863
865
|
this.renderer.renderRows();
|
|
864
866
|
|
|
865
867
|
if(this.firstRender){
|
package/src/js/core/Tabulator.js
CHANGED
|
@@ -35,6 +35,7 @@ class Tabulator {
|
|
|
35
35
|
this.browserSlow = false; //handle reduced functionality for slower browsers
|
|
36
36
|
this.browserMobile = false; //check if running on moble, prevent resize cancelling edit on keyboard appearence
|
|
37
37
|
this.rtl = false; //check if the table is in RTL mode
|
|
38
|
+
this.originalElement = null; //hold original table element if it has been replaced
|
|
38
39
|
|
|
39
40
|
this.componentFunctionBinder = new ComponentFuctionBinder(this); //bind component functions
|
|
40
41
|
this.dataLoader = false; //bind component functions
|
|
@@ -93,7 +94,7 @@ class Tabulator {
|
|
|
93
94
|
|
|
94
95
|
this._mapDepricatedFunctionality();
|
|
95
96
|
|
|
96
|
-
this.externalEvents = new ExternalEventBus(this.options, this.options.debugEventsExternal);
|
|
97
|
+
this.externalEvents = new ExternalEventBus(this, this.options, this.options.debugEventsExternal);
|
|
97
98
|
this.eventBus = new InternalEventBus(this.options.debugEventsInternal);
|
|
98
99
|
|
|
99
100
|
this.interactionMonitor = new InteractionMonitor(this);
|
|
@@ -104,28 +105,6 @@ class Tabulator {
|
|
|
104
105
|
this.footerManager.initialize();
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
rtlCheck(){
|
|
108
|
-
var style = window.getComputedStyle(this.element);
|
|
109
|
-
|
|
110
|
-
switch(this.options.textDirection){
|
|
111
|
-
case"auto":
|
|
112
|
-
if(style.direction !== "rtl"){
|
|
113
|
-
break;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
case "rtl":
|
|
117
|
-
this.element.classList.add("tabulator-rtl");
|
|
118
|
-
this.rtl = true;
|
|
119
|
-
break;
|
|
120
|
-
|
|
121
|
-
case "ltr":
|
|
122
|
-
this.element.classList.add("tabulator-ltr");
|
|
123
|
-
|
|
124
|
-
default:
|
|
125
|
-
this.rtl = false;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
108
|
//convert depricated functionality to new functions
|
|
130
109
|
_mapDepricatedFunctionality(){
|
|
131
110
|
//all previously deprecated functionality removed in the 5.0 release
|
|
@@ -153,10 +132,12 @@ class Tabulator {
|
|
|
153
132
|
this.externalEvents.dispatch("tableBuilding");
|
|
154
133
|
this.eventBus.dispatch("table-building");
|
|
155
134
|
|
|
156
|
-
this.
|
|
135
|
+
this._rtlCheck();
|
|
157
136
|
|
|
158
137
|
this._buildElement();
|
|
159
138
|
|
|
139
|
+
this._initializeTable();
|
|
140
|
+
|
|
160
141
|
this._loadInitialData();
|
|
161
142
|
|
|
162
143
|
this.initialized = true;
|
|
@@ -164,6 +145,28 @@ class Tabulator {
|
|
|
164
145
|
this.externalEvents.dispatch("tableBuilt");
|
|
165
146
|
}
|
|
166
147
|
|
|
148
|
+
_rtlCheck(){
|
|
149
|
+
var style = window.getComputedStyle(this.element);
|
|
150
|
+
|
|
151
|
+
switch(this.options.textDirection){
|
|
152
|
+
case"auto":
|
|
153
|
+
if(style.direction !== "rtl"){
|
|
154
|
+
break;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
case "rtl":
|
|
158
|
+
this.element.classList.add("tabulator-rtl");
|
|
159
|
+
this.rtl = true;
|
|
160
|
+
break;
|
|
161
|
+
|
|
162
|
+
case "ltr":
|
|
163
|
+
this.element.classList.add("tabulator-ltr");
|
|
164
|
+
|
|
165
|
+
default:
|
|
166
|
+
this.rtl = false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
167
170
|
//clear pointers to objects in default config object
|
|
168
171
|
_clearObjectPointers(){
|
|
169
172
|
this.options.columns = this.options.columns.slice(0);
|
|
@@ -176,7 +179,28 @@ class Tabulator {
|
|
|
176
179
|
//build tabulator element
|
|
177
180
|
_buildElement(){
|
|
178
181
|
var element = this.element,
|
|
179
|
-
options = this.options
|
|
182
|
+
options = this.options,
|
|
183
|
+
newElement;
|
|
184
|
+
|
|
185
|
+
if(element.tagName === "TABLE"){
|
|
186
|
+
this.originalElement = this.element;
|
|
187
|
+
newElement = document.createElement("div");
|
|
188
|
+
|
|
189
|
+
//transfer attributes to new element
|
|
190
|
+
var attributes = element.attributes;
|
|
191
|
+
|
|
192
|
+
// loop through attributes and apply them on div
|
|
193
|
+
for(var i in attributes){
|
|
194
|
+
if(typeof attributes[i] == "object"){
|
|
195
|
+
newElement.setAttribute(attributes[i].name, attributes[i].value);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// replace table with div element
|
|
200
|
+
element.parentNode.replaceChild(newElement, element);
|
|
201
|
+
|
|
202
|
+
this.element = element = newElement;
|
|
203
|
+
}
|
|
180
204
|
|
|
181
205
|
element.classList.add("tabulator");
|
|
182
206
|
element.setAttribute("role", "grid");
|
|
@@ -201,6 +225,12 @@ class Tabulator {
|
|
|
201
225
|
options.maxHeight = isNaN(options.maxHeight) ? options.maxHeight : options.maxHeight + "px";
|
|
202
226
|
element.style.maxHeight = options.maxHeight;
|
|
203
227
|
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
//initialize core systems and modules
|
|
231
|
+
_initializeTable(){
|
|
232
|
+
var element = this.element,
|
|
233
|
+
options = this.options;
|
|
204
234
|
|
|
205
235
|
this.columnManager.initialize();
|
|
206
236
|
this.rowManager.initialize();
|
|
@@ -216,7 +246,6 @@ class Tabulator {
|
|
|
216
246
|
|
|
217
247
|
//configure placeholder element
|
|
218
248
|
if(typeof options.placeholder == "string"){
|
|
219
|
-
|
|
220
249
|
var el = document.createElement("div");
|
|
221
250
|
el.classList.add("tabulator-placeholder");
|
|
222
251
|
|
|
@@ -380,68 +409,80 @@ class Tabulator {
|
|
|
380
409
|
|
|
381
410
|
//replace data, keeping table in position with same sort
|
|
382
411
|
replaceData(data, params, config){
|
|
383
|
-
|
|
412
|
+
if(this.initialized){
|
|
413
|
+
return this.dataLoader.load(data, params, config, true, true);
|
|
414
|
+
}else{
|
|
415
|
+
console.warn("replaceData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
|
|
416
|
+
}
|
|
384
417
|
}
|
|
385
418
|
|
|
386
419
|
//update table data
|
|
387
420
|
updateData(data){
|
|
388
421
|
var responses = 0;
|
|
389
422
|
|
|
390
|
-
|
|
391
|
-
|
|
423
|
+
if(this.initialized){
|
|
424
|
+
return new Promise((resolve, reject) => {
|
|
425
|
+
this.dataLoader.blockActiveLoad();
|
|
392
426
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
427
|
+
if(typeof data === "string"){
|
|
428
|
+
data = JSON.parse(data);
|
|
429
|
+
}
|
|
396
430
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
431
|
+
if(data){
|
|
432
|
+
data.forEach((item) => {
|
|
433
|
+
var row = this.rowManager.findRow(item[this.options.index]);
|
|
400
434
|
|
|
401
|
-
|
|
402
|
-
|
|
435
|
+
if(row){
|
|
436
|
+
responses++;
|
|
403
437
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
438
|
+
row.updateData(item)
|
|
439
|
+
.then(()=>{
|
|
440
|
+
responses--;
|
|
407
441
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
442
|
+
if(!responses){
|
|
443
|
+
resolve();
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}else{
|
|
449
|
+
console.warn("Update Error - No data provided");
|
|
450
|
+
reject("Update Error - No data provided");
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
}else{
|
|
454
|
+
console.warn("updateData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
|
|
455
|
+
}
|
|
419
456
|
}
|
|
420
457
|
|
|
421
458
|
addData(data, pos, index){
|
|
422
|
-
|
|
423
|
-
|
|
459
|
+
if(this.initialized){
|
|
460
|
+
return new Promise((resolve, reject) => {
|
|
461
|
+
this.dataLoader.blockActiveLoad();
|
|
424
462
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
463
|
+
if(typeof data === "string"){
|
|
464
|
+
data = JSON.parse(data);
|
|
465
|
+
}
|
|
428
466
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
467
|
+
if(data){
|
|
468
|
+
this.rowManager.addRows(data, pos, index)
|
|
469
|
+
.then((rows) => {
|
|
470
|
+
var output = [];
|
|
433
471
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
472
|
+
rows.forEach(function(row){
|
|
473
|
+
output.push(row.getComponent());
|
|
474
|
+
});
|
|
437
475
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
476
|
+
resolve(output);
|
|
477
|
+
});
|
|
478
|
+
}else{
|
|
479
|
+
console.warn("Update Error - No data provided");
|
|
480
|
+
reject("Update Error - No data provided");
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
}else{
|
|
484
|
+
console.warn("addData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
|
|
485
|
+
}
|
|
445
486
|
}
|
|
446
487
|
|
|
447
488
|
//update table data
|
|
@@ -449,46 +490,50 @@ class Tabulator {
|
|
|
449
490
|
var rows = [],
|
|
450
491
|
responses = 0;
|
|
451
492
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
if(typeof data === "string"){
|
|
456
|
-
data = JSON.parse(data);
|
|
457
|
-
}
|
|
493
|
+
if(this.initialized){
|
|
494
|
+
return new Promise((resolve, reject) => {
|
|
495
|
+
this.dataLoader.blockActiveLoad();
|
|
458
496
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
497
|
+
if(typeof data === "string"){
|
|
498
|
+
data = JSON.parse(data);
|
|
499
|
+
}
|
|
462
500
|
|
|
463
|
-
|
|
501
|
+
if(data){
|
|
502
|
+
data.forEach((item) => {
|
|
503
|
+
var row = this.rowManager.findRow(item[this.options.index]);
|
|
464
504
|
|
|
465
|
-
|
|
466
|
-
row.updateData(item)
|
|
467
|
-
.then(()=>{
|
|
468
|
-
responses--;
|
|
469
|
-
rows.push(row.getComponent());
|
|
505
|
+
responses++;
|
|
470
506
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
507
|
+
if(row){
|
|
508
|
+
row.updateData(item)
|
|
509
|
+
.then(()=>{
|
|
510
|
+
responses--;
|
|
511
|
+
rows.push(row.getComponent());
|
|
512
|
+
|
|
513
|
+
if(!responses){
|
|
514
|
+
resolve(rows);
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
}else{
|
|
518
|
+
this.rowManager.addRows(item)
|
|
519
|
+
.then((newRows)=>{
|
|
520
|
+
responses--;
|
|
521
|
+
rows.push(newRows[0].getComponent());
|
|
522
|
+
|
|
523
|
+
if(!responses){
|
|
524
|
+
resolve(rows);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}else{
|
|
530
|
+
console.warn("Update Error - No data provided");
|
|
531
|
+
reject("Update Error - No data provided");
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
}else{
|
|
535
|
+
console.warn("updateOrAddData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
|
|
536
|
+
}
|
|
492
537
|
}
|
|
493
538
|
|
|
494
539
|
//get row object
|
|
@@ -553,14 +598,18 @@ class Tabulator {
|
|
|
553
598
|
|
|
554
599
|
//add row to table
|
|
555
600
|
addRow(data, pos, index){
|
|
556
|
-
if(
|
|
557
|
-
data
|
|
558
|
-
|
|
601
|
+
if(this.initialized){
|
|
602
|
+
if(typeof data === "string"){
|
|
603
|
+
data = JSON.parse(data);
|
|
604
|
+
}
|
|
559
605
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
606
|
+
return this.rowManager.addRows(data, pos, index)
|
|
607
|
+
.then((rows)=>{
|
|
608
|
+
return rows[0].getComponent();
|
|
609
|
+
});
|
|
610
|
+
}else{
|
|
611
|
+
console.warn("addRow failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
|
|
612
|
+
}
|
|
564
613
|
}
|
|
565
614
|
|
|
566
615
|
//update a row if it exitsts otherwise create it
|
|
@@ -626,7 +675,11 @@ class Tabulator {
|
|
|
626
675
|
}
|
|
627
676
|
|
|
628
677
|
getRows(active){
|
|
629
|
-
|
|
678
|
+
if(this.initialized){
|
|
679
|
+
return this.rowManager.getComponents(active);
|
|
680
|
+
}else{
|
|
681
|
+
console.warn("getRows failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
|
|
682
|
+
}
|
|
630
683
|
}
|
|
631
684
|
|
|
632
685
|
//get position of row in table
|
|
@@ -643,7 +696,11 @@ class Tabulator {
|
|
|
643
696
|
|
|
644
697
|
/////////////// Column Functions ///////////////
|
|
645
698
|
setColumns(definition){
|
|
646
|
-
this.
|
|
699
|
+
if(this.initialized){
|
|
700
|
+
this.columnManager.setColumns(definition);
|
|
701
|
+
}else{
|
|
702
|
+
console.warn("setColumns failed - table not yet initialized. To set initial data please use the 'columns' property in the table constructor.")
|
|
703
|
+
}
|
|
647
704
|
}
|
|
648
705
|
|
|
649
706
|
getColumns(structured){
|
|
@@ -765,8 +822,12 @@ class Tabulator {
|
|
|
765
822
|
//////////// General Public Functions ////////////
|
|
766
823
|
//redraw list without updating data
|
|
767
824
|
redraw(force){
|
|
768
|
-
this.
|
|
769
|
-
|
|
825
|
+
if(this.initialized){
|
|
826
|
+
this.columnManager.redraw(force);
|
|
827
|
+
this.rowManager.redraw(force);
|
|
828
|
+
}else{
|
|
829
|
+
console.warn("redraw failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
|
|
830
|
+
}
|
|
770
831
|
}
|
|
771
832
|
|
|
772
833
|
setHeight(height){
|
|
@@ -668,7 +668,7 @@ class Column extends CoreFeature{
|
|
|
668
668
|
this.reinitializeWidth();
|
|
669
669
|
}
|
|
670
670
|
|
|
671
|
-
this.table.columnManager.
|
|
671
|
+
this.table.columnManager.verticalAlignHeaders();
|
|
672
672
|
|
|
673
673
|
this.dispatch("column-show", this, responsiveToggle);
|
|
674
674
|
|
|
@@ -693,7 +693,7 @@ class Column extends CoreFeature{
|
|
|
693
693
|
|
|
694
694
|
this.element.style.display = "none";
|
|
695
695
|
|
|
696
|
-
this.table.columnManager.
|
|
696
|
+
this.table.columnManager.verticalAlignHeaders();
|
|
697
697
|
|
|
698
698
|
if(this.parent.isGroup){
|
|
699
699
|
this.parent.checkColumnVisibility();
|
|
@@ -89,7 +89,7 @@ export default class DataLoader extends CoreFeature{
|
|
|
89
89
|
this.hideLoader();
|
|
90
90
|
|
|
91
91
|
if(rowData !== false){
|
|
92
|
-
this.dispatchExternal("dataLoaded",
|
|
92
|
+
this.dispatchExternal("dataLoaded", rowData);
|
|
93
93
|
this.table.rowManager.setData(rowData, replace, !replace);
|
|
94
94
|
}
|
|
95
95
|
}else{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export default class ExternalEventBus {
|
|
2
2
|
|
|
3
|
-
constructor(optionsList, debug){
|
|
3
|
+
constructor(table, optionsList, debug){
|
|
4
|
+
this.table = table;
|
|
4
5
|
this.events = {};
|
|
5
6
|
this.optionsList = optionsList || {};
|
|
6
7
|
this.subscriptionNotifiers = {};
|
|
@@ -78,7 +79,7 @@ export default class ExternalEventBus {
|
|
|
78
79
|
|
|
79
80
|
if(this.events[key]){
|
|
80
81
|
this.events[key].forEach((callback, i) => {
|
|
81
|
-
let callResult = callback.apply(this, args);
|
|
82
|
+
let callResult = callback.apply(this.table, args);
|
|
82
83
|
|
|
83
84
|
if(!i){
|
|
84
85
|
result = callResult;
|
|
@@ -13,18 +13,35 @@ export default class Helpers{
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
static deepClone(obj){
|
|
17
|
-
var
|
|
16
|
+
static deepClone(obj, clone, list = []){
|
|
17
|
+
var objectProto = {}.__proto__,
|
|
18
|
+
arrayProto = [].__proto__;
|
|
19
|
+
|
|
20
|
+
if (!clone){
|
|
21
|
+
clone = Object.assign(Array.isArray(obj) ? [] : {}, obj);
|
|
22
|
+
}
|
|
18
23
|
|
|
19
24
|
for(var i in obj) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
let subject = obj[i],
|
|
26
|
+
match, copy;
|
|
27
|
+
|
|
28
|
+
if(subject != null && typeof subject === "object" && (subject.__proto__ === objectProto || subject.__proto__ === arrayProto)){
|
|
29
|
+
match = list.findIndex((item) => {
|
|
30
|
+
return item.subject === subject;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if(match > -1){
|
|
34
|
+
clone[i] = list[match].copy;
|
|
35
|
+
}else{
|
|
36
|
+
copy = Object.assign(Array.isArray(subject) ? [] : {}, subject);
|
|
37
|
+
|
|
38
|
+
list.unshift({subject, copy});
|
|
39
|
+
|
|
40
|
+
clone[i] = this.deepClone(subject, copy, list);
|
|
25
41
|
}
|
|
26
42
|
}
|
|
27
43
|
}
|
|
44
|
+
|
|
28
45
|
return clone;
|
|
29
46
|
}
|
|
30
47
|
}
|