tabulator-tables 5.1.7 → 5.2.1
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/.github/ISSUE_TEMPLATE/bug_report.md +3 -2
- package/.github/ISSUE_TEMPLATE/feature_request.md +1 -1
- package/bower.json +1 -1
- package/dist/css/tabulator.css +64 -51
- 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 +64 -51
- 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 +64 -51
- 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 +1580 -0
- package/dist/css/tabulator_bootstrap5.css.map +1 -0
- package/dist/css/tabulator_bootstrap5.min.css +2 -0
- package/dist/css/tabulator_bootstrap5.min.css.map +1 -0
- package/dist/css/tabulator_bulma.css +64 -51
- 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 +64 -51
- 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 +64 -51
- 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 +64 -51
- 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 +64 -51
- 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 +64 -51
- 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 +64 -51
- 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 +2543 -1658
- 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 +2746 -2069
- 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/FooterManager.js +6 -13
- package/src/js/core/Module.js +44 -2
- package/src/js/core/Tabulator.js +341 -289
- package/src/js/core/cell/Cell.js +9 -38
- package/src/js/core/column/Column.js +8 -44
- package/src/js/core/column/defaults/options.js +0 -2
- package/src/js/core/defaults/options.js +5 -2
- package/src/js/core/modules/optional.js +2 -0
- package/src/js/core/row/Row.js +127 -118
- package/src/js/core/tools/Alert.js +63 -0
- package/src/js/core/tools/ComponentFunctionBinder.js +3 -3
- package/src/js/core/tools/DataLoader.js +12 -84
- package/src/js/core/tools/InteractionMonitor.js +1 -1
- package/src/js/core/tools/ModuleBinder.js +30 -23
- package/src/js/core/tools/Popup.js +251 -0
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +2 -2
- package/src/js/modules/Edit/Edit.js +6 -25
- package/src/js/modules/Edit/List.js +997 -0
- package/src/js/modules/Edit/defaults/editors/autocomplete.js +6 -446
- package/src/js/modules/Edit/defaults/editors/input.js +4 -0
- package/src/js/modules/Edit/defaults/editors/list.js +7 -0
- package/src/js/modules/Edit/defaults/editors/number.js +4 -0
- package/src/js/modules/Edit/defaults/editors/select.js +5 -584
- package/src/js/modules/Edit/defaults/editors/textarea.js +4 -0
- package/src/js/modules/Edit/defaults/editors/tickCross.js +17 -5
- package/src/js/modules/Edit/defaults/editors.js +2 -0
- package/src/js/modules/Filter/Filter.js +7 -4
- package/src/js/modules/Format/defaults/formatters/datetime.js +10 -4
- package/src/js/modules/Format/defaults/formatters/datetimediff.js +10 -3
- package/src/js/modules/Format/defaults/formatters/link.js +12 -1
- package/src/js/modules/Format/defaults/formatters/money.js +5 -3
- package/src/js/modules/Format/defaults/formatters/tickCross.js +2 -1
- package/src/js/modules/FrozenColumns/FrozenColumns.js +30 -8
- package/src/js/modules/HtmlTableImport/HtmlTableImport.js +5 -1
- package/src/js/modules/Menu/Menu.js +59 -157
- package/src/js/modules/Mutator/Mutator.js +20 -0
- package/src/js/modules/Page/Page.js +7 -3
- package/src/js/modules/Persistence/Persistence.js +1 -1
- package/src/js/modules/Popup/Popup.js +194 -0
- package/src/js/modules/ResizeColumns/ResizeColumns.js +138 -81
- package/src/js/modules/Sort/defaults/sorters/datetime.js +15 -2
- package/src/js/modules/Tooltip/Tooltip.js +132 -0
- package/src/js/modules/Validate/Validate.js +107 -71
- package/src/scss/tabulator.scss +354 -349
- package/src/scss/themes/bootstrap/functions5.scss +302 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +546 -0
- package/src/scss/themes/bootstrap/variables5.scss +1641 -0
package/src/js/core/Tabulator.js
CHANGED
|
@@ -18,15 +18,18 @@ import ModuleBinder from './tools/ModuleBinder.js';
|
|
|
18
18
|
|
|
19
19
|
import OptionsList from './tools/OptionsList.js';
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
import Alert from './tools/Alert.js';
|
|
22
22
|
|
|
23
|
+
class Tabulator {
|
|
24
|
+
|
|
23
25
|
constructor(element, options){
|
|
24
|
-
|
|
26
|
+
|
|
25
27
|
this.options = {};
|
|
26
|
-
|
|
28
|
+
|
|
27
29
|
this.columnManager = null; // hold Column Manager
|
|
28
30
|
this.rowManager = null; //hold Row Manager
|
|
29
31
|
this.footerManager = null; //holder Footer Manager
|
|
32
|
+
this.alertManager = null; //hold Alert Manager
|
|
30
33
|
this.vdomHoz = null; //holder horizontal virtual dom
|
|
31
34
|
this.externalEvents = null; //handle external event messaging
|
|
32
35
|
this.eventBus = null; //handle internal event messaging
|
|
@@ -36,38 +39,38 @@ class Tabulator {
|
|
|
36
39
|
this.browserMobile = false; //check if running on mobile, prevent resize cancelling edit on keyboard appearance
|
|
37
40
|
this.rtl = false; //check if the table is in RTL mode
|
|
38
41
|
this.originalElement = null; //hold original table element if it has been replaced
|
|
39
|
-
|
|
42
|
+
|
|
40
43
|
this.componentFunctionBinder = new ComponentFunctionBinder(this); //bind component functions
|
|
41
44
|
this.dataLoader = false; //bind component functions
|
|
42
|
-
|
|
45
|
+
|
|
43
46
|
this.modules = {}; //hold all modules bound to this table
|
|
44
47
|
this.modulesCore = []; //hold core modules bound to this table (for initialization purposes)
|
|
45
48
|
this.modulesRegular = []; //hold regular modules bound to this table (for initialization purposes)
|
|
46
|
-
|
|
49
|
+
|
|
47
50
|
this.optionsList = new OptionsList(this, "table constructor");
|
|
48
|
-
|
|
51
|
+
|
|
49
52
|
this.initialized = false;
|
|
50
|
-
|
|
53
|
+
|
|
51
54
|
if(this.initializeElement(element)){
|
|
52
|
-
|
|
55
|
+
|
|
53
56
|
this.initializeCoreSystems(options);
|
|
54
|
-
|
|
57
|
+
|
|
55
58
|
//delay table creation to allow event bindings immediately after the constructor
|
|
56
59
|
setTimeout(() => {
|
|
57
60
|
this._create();
|
|
58
61
|
})
|
|
59
62
|
}
|
|
60
|
-
|
|
63
|
+
|
|
61
64
|
TableRegistry.register(this); //register table for inter-device communication
|
|
62
65
|
}
|
|
63
|
-
|
|
66
|
+
|
|
64
67
|
initializeElement(element){
|
|
65
68
|
if(typeof HTMLElement !== "undefined" && element instanceof HTMLElement){
|
|
66
69
|
this.element = element;
|
|
67
70
|
return true;
|
|
68
71
|
}else if(typeof element === "string"){
|
|
69
72
|
this.element = document.querySelector(element);
|
|
70
|
-
|
|
73
|
+
|
|
71
74
|
if(this.element){
|
|
72
75
|
return true;
|
|
73
76
|
}else{
|
|
@@ -79,223 +82,224 @@ class Tabulator {
|
|
|
79
82
|
return false;
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
|
-
|
|
85
|
+
|
|
83
86
|
initializeCoreSystems(options){
|
|
84
87
|
this.columnManager = new ColumnManager(this);
|
|
85
88
|
this.rowManager = new RowManager(this);
|
|
86
89
|
this.footerManager = new FooterManager(this);
|
|
87
90
|
this.dataLoader = new DataLoader(this);
|
|
88
|
-
|
|
91
|
+
this.alertManager = new Alert(this);
|
|
92
|
+
|
|
89
93
|
this.bindModules();
|
|
90
|
-
|
|
94
|
+
|
|
91
95
|
this.options = this.optionsList.generate(Tabulator.defaultOptions, options)
|
|
92
|
-
|
|
96
|
+
|
|
93
97
|
this._clearObjectPointers();
|
|
94
|
-
|
|
98
|
+
|
|
95
99
|
this._mapDeprecatedFunctionality();
|
|
96
|
-
|
|
100
|
+
|
|
97
101
|
this.externalEvents = new ExternalEventBus(this, this.options, this.options.debugEventsExternal);
|
|
98
102
|
this.eventBus = new InternalEventBus(this.options.debugEventsInternal);
|
|
99
|
-
|
|
103
|
+
|
|
100
104
|
this.interactionMonitor = new InteractionMonitor(this);
|
|
101
|
-
|
|
105
|
+
|
|
102
106
|
this.dataLoader.initialize();
|
|
103
107
|
// this.columnManager.initialize();
|
|
104
108
|
// this.rowManager.initialize();
|
|
105
109
|
this.footerManager.initialize();
|
|
106
110
|
}
|
|
107
|
-
|
|
111
|
+
|
|
108
112
|
//convert deprecated functionality to new functions
|
|
109
113
|
_mapDeprecatedFunctionality(){
|
|
110
114
|
//all previously deprecated functionality removed in the 5.0 release
|
|
111
115
|
}
|
|
112
|
-
|
|
116
|
+
|
|
113
117
|
_clearSelection(){
|
|
114
|
-
|
|
118
|
+
|
|
115
119
|
this.element.classList.add("tabulator-block-select");
|
|
116
|
-
|
|
120
|
+
|
|
117
121
|
if (window.getSelection) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
if (window.getSelection().empty) { // Chrome
|
|
123
|
+
window.getSelection().empty();
|
|
124
|
+
} else if (window.getSelection().removeAllRanges) { // Firefox
|
|
125
|
+
window.getSelection().removeAllRanges();
|
|
126
|
+
}
|
|
123
127
|
} else if (document.selection) { // IE?
|
|
124
128
|
document.selection.empty();
|
|
125
129
|
}
|
|
126
|
-
|
|
130
|
+
|
|
127
131
|
this.element.classList.remove("tabulator-block-select");
|
|
128
132
|
}
|
|
129
|
-
|
|
133
|
+
|
|
130
134
|
//create table
|
|
131
135
|
_create(){
|
|
132
136
|
this.externalEvents.dispatch("tableBuilding");
|
|
133
137
|
this.eventBus.dispatch("table-building");
|
|
134
|
-
|
|
138
|
+
|
|
135
139
|
this._rtlCheck();
|
|
136
|
-
|
|
140
|
+
|
|
137
141
|
this._buildElement();
|
|
138
|
-
|
|
142
|
+
|
|
139
143
|
this._initializeTable();
|
|
140
|
-
|
|
144
|
+
|
|
141
145
|
this._loadInitialData();
|
|
142
|
-
|
|
146
|
+
|
|
143
147
|
this.initialized = true;
|
|
144
|
-
|
|
148
|
+
|
|
145
149
|
this.externalEvents.dispatch("tableBuilt");
|
|
146
150
|
}
|
|
147
|
-
|
|
151
|
+
|
|
148
152
|
_rtlCheck(){
|
|
149
153
|
var style = window.getComputedStyle(this.element);
|
|
150
|
-
|
|
154
|
+
|
|
151
155
|
switch(this.options.textDirection){
|
|
152
156
|
case"auto":
|
|
153
157
|
if(style.direction !== "rtl"){
|
|
154
158
|
break;
|
|
155
159
|
};
|
|
156
|
-
|
|
160
|
+
|
|
157
161
|
case "rtl":
|
|
158
162
|
this.element.classList.add("tabulator-rtl");
|
|
159
163
|
this.rtl = true;
|
|
160
164
|
break;
|
|
161
|
-
|
|
165
|
+
|
|
162
166
|
case "ltr":
|
|
163
167
|
this.element.classList.add("tabulator-ltr");
|
|
164
|
-
|
|
168
|
+
|
|
165
169
|
default:
|
|
166
170
|
this.rtl = false;
|
|
167
171
|
}
|
|
168
172
|
}
|
|
169
|
-
|
|
173
|
+
|
|
170
174
|
//clear pointers to objects in default config object
|
|
171
175
|
_clearObjectPointers(){
|
|
172
176
|
this.options.columns = this.options.columns.slice(0);
|
|
173
|
-
|
|
177
|
+
|
|
174
178
|
if(Array.isArray(this.options.data) && !this.options.reactiveData){
|
|
175
179
|
this.options.data = this.options.data.slice(0);
|
|
176
180
|
}
|
|
177
181
|
}
|
|
178
|
-
|
|
182
|
+
|
|
179
183
|
//build tabulator element
|
|
180
184
|
_buildElement(){
|
|
181
185
|
var element = this.element,
|
|
182
186
|
options = this.options,
|
|
183
187
|
newElement;
|
|
184
|
-
|
|
188
|
+
|
|
185
189
|
if(element.tagName === "TABLE"){
|
|
186
190
|
this.originalElement = this.element;
|
|
187
191
|
newElement = document.createElement("div");
|
|
188
|
-
|
|
192
|
+
|
|
189
193
|
//transfer attributes to new element
|
|
190
194
|
var attributes = element.attributes;
|
|
191
|
-
|
|
195
|
+
|
|
192
196
|
// loop through attributes and apply them on div
|
|
193
197
|
for(var i in attributes){
|
|
194
198
|
if(typeof attributes[i] == "object"){
|
|
195
199
|
newElement.setAttribute(attributes[i].name, attributes[i].value);
|
|
196
200
|
}
|
|
197
201
|
}
|
|
198
|
-
|
|
202
|
+
|
|
199
203
|
// replace table with div element
|
|
200
204
|
element.parentNode.replaceChild(newElement, element);
|
|
201
|
-
|
|
205
|
+
|
|
202
206
|
this.element = element = newElement;
|
|
203
207
|
}
|
|
204
|
-
|
|
208
|
+
|
|
205
209
|
element.classList.add("tabulator");
|
|
206
210
|
element.setAttribute("role", "grid");
|
|
207
|
-
|
|
211
|
+
|
|
208
212
|
//empty element
|
|
209
213
|
while(element.firstChild) element.removeChild(element.firstChild);
|
|
210
|
-
|
|
214
|
+
|
|
211
215
|
//set table height
|
|
212
216
|
if(options.height){
|
|
213
217
|
options.height = isNaN(options.height) ? options.height : options.height + "px";
|
|
214
218
|
element.style.height = options.height;
|
|
215
219
|
}
|
|
216
|
-
|
|
220
|
+
|
|
217
221
|
//set table min height
|
|
218
222
|
if(options.minHeight !== false){
|
|
219
223
|
options.minHeight = isNaN(options.minHeight) ? options.minHeight : options.minHeight + "px";
|
|
220
224
|
element.style.minHeight = options.minHeight;
|
|
221
225
|
}
|
|
222
|
-
|
|
226
|
+
|
|
223
227
|
//set table maxHeight
|
|
224
228
|
if(options.maxHeight !== false){
|
|
225
229
|
options.maxHeight = isNaN(options.maxHeight) ? options.maxHeight : options.maxHeight + "px";
|
|
226
230
|
element.style.maxHeight = options.maxHeight;
|
|
227
231
|
}
|
|
228
232
|
}
|
|
229
|
-
|
|
233
|
+
|
|
230
234
|
//initialize core systems and modules
|
|
231
235
|
_initializeTable(){
|
|
232
236
|
var element = this.element,
|
|
233
237
|
options = this.options;
|
|
234
|
-
|
|
238
|
+
|
|
235
239
|
this.interactionMonitor.initialize();
|
|
236
|
-
|
|
240
|
+
|
|
237
241
|
this.columnManager.initialize();
|
|
238
242
|
this.rowManager.initialize();
|
|
239
|
-
|
|
243
|
+
|
|
240
244
|
this._detectBrowser();
|
|
241
|
-
|
|
245
|
+
|
|
242
246
|
//initialize core modules
|
|
243
247
|
this.modulesCore.forEach((mod) => {
|
|
244
248
|
mod.initialize();
|
|
245
249
|
})
|
|
246
|
-
|
|
250
|
+
|
|
247
251
|
//build table elements
|
|
248
252
|
element.appendChild(this.columnManager.getElement());
|
|
249
253
|
element.appendChild(this.rowManager.getElement());
|
|
250
|
-
|
|
254
|
+
|
|
251
255
|
if(options.footerElement){
|
|
252
256
|
this.footerManager.activate();
|
|
253
257
|
}
|
|
254
|
-
|
|
258
|
+
|
|
255
259
|
if(options.autoColumns && options.data){
|
|
256
|
-
|
|
260
|
+
|
|
257
261
|
this.columnManager.generateColumnsFromRowData(this.options.data);
|
|
258
262
|
}
|
|
259
|
-
|
|
263
|
+
|
|
260
264
|
//initialize regular modules
|
|
261
265
|
this.modulesRegular.forEach((mod) => {
|
|
262
266
|
mod.initialize();
|
|
263
267
|
});
|
|
264
|
-
|
|
268
|
+
|
|
265
269
|
this.columnManager.setColumns(options.columns);
|
|
266
|
-
|
|
270
|
+
|
|
267
271
|
this.eventBus.dispatch("table-built");
|
|
268
272
|
}
|
|
269
|
-
|
|
273
|
+
|
|
270
274
|
_loadInitialData(){
|
|
271
275
|
this.dataLoader.load(this.options.data);
|
|
272
276
|
}
|
|
273
|
-
|
|
277
|
+
|
|
274
278
|
//deconstructor
|
|
275
279
|
destroy(){
|
|
276
280
|
var element = this.element;
|
|
277
|
-
|
|
281
|
+
|
|
278
282
|
TableRegistry.deregister(this); //deregister table from inter-device communication
|
|
279
|
-
|
|
283
|
+
|
|
280
284
|
this.eventBus.dispatch("table-destroy");
|
|
281
|
-
|
|
285
|
+
|
|
282
286
|
//clear row data
|
|
283
287
|
this.rowManager.rows.forEach(function(row){
|
|
284
288
|
row.wipe();
|
|
285
289
|
});
|
|
286
|
-
|
|
290
|
+
|
|
287
291
|
this.rowManager.rows = [];
|
|
288
292
|
this.rowManager.activeRows = [];
|
|
289
293
|
this.rowManager.displayRows = [];
|
|
290
|
-
|
|
294
|
+
|
|
291
295
|
//clear DOM
|
|
292
296
|
while(element.firstChild) element.removeChild(element.firstChild);
|
|
293
297
|
element.classList.remove("tabulator");
|
|
294
298
|
}
|
|
295
|
-
|
|
299
|
+
|
|
296
300
|
_detectBrowser(){
|
|
297
301
|
var ua = navigator.userAgent||navigator.vendor||window.opera;
|
|
298
|
-
|
|
302
|
+
|
|
299
303
|
if(ua.indexOf("Trident") > -1){
|
|
300
304
|
this.browser = "ie";
|
|
301
305
|
this.browserSlow = true;
|
|
@@ -309,179 +313,197 @@ class Tabulator {
|
|
|
309
313
|
this.browser = "other";
|
|
310
314
|
this.browserSlow = false;
|
|
311
315
|
}
|
|
312
|
-
|
|
316
|
+
|
|
313
317
|
this.browserMobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(ua)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(ua.slice(0,4));
|
|
314
318
|
}
|
|
315
|
-
|
|
319
|
+
|
|
320
|
+
initGuard(func, msg){
|
|
321
|
+
var stack, line;
|
|
322
|
+
|
|
323
|
+
if(this.options.debugInitialization && !this.initialized){
|
|
324
|
+
if(!func){
|
|
325
|
+
stack = new Error().stack.split("\n");
|
|
326
|
+
|
|
327
|
+
line = stack[0] == "Error" ? stack[2] : stack[1];
|
|
328
|
+
|
|
329
|
+
if(line[0] == " "){
|
|
330
|
+
func = line.trim().split(" ")[1].split(".")[1];
|
|
331
|
+
}else{
|
|
332
|
+
func = line.trim().split("@")[0];
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
console.warn("Table Not Initialized - Calling the " + func + " function before the table is initialized may result in inconsistent behavior, Please wait for the `tableBuilt` event before calling this function." + (msg ? " " + msg : ""));
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return this.initialized;
|
|
340
|
+
}
|
|
341
|
+
|
|
316
342
|
////////////////// Data Handling //////////////////
|
|
317
343
|
//block table redrawing
|
|
318
344
|
blockRedraw(){
|
|
345
|
+
this.initGuard();
|
|
346
|
+
|
|
319
347
|
return this.rowManager.blockRedraw();
|
|
320
348
|
}
|
|
321
|
-
|
|
349
|
+
|
|
322
350
|
//restore table redrawing
|
|
323
351
|
restoreRedraw(){
|
|
352
|
+
this.initGuard();
|
|
353
|
+
|
|
324
354
|
return this.rowManager.restoreRedraw();
|
|
325
355
|
}
|
|
326
|
-
|
|
356
|
+
|
|
327
357
|
//load data
|
|
328
358
|
setData(data, params, config){
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
console.warn("setData failed - table not yet initialized. To set initial data please use the 'data' property in the table constructor.")
|
|
333
|
-
}
|
|
359
|
+
this.initGuard(false, "To set initial data please use the 'data' property in the table constructor.");
|
|
360
|
+
|
|
361
|
+
return this.dataLoader.load(data, params, config, false);
|
|
334
362
|
}
|
|
335
|
-
|
|
363
|
+
|
|
336
364
|
//clear data
|
|
337
365
|
clearData(){
|
|
366
|
+
this.initGuard();
|
|
367
|
+
|
|
338
368
|
this.dataLoader.blockActiveLoad();
|
|
339
369
|
this.rowManager.clearData();
|
|
340
370
|
}
|
|
341
|
-
|
|
371
|
+
|
|
342
372
|
//get table data array
|
|
343
373
|
getData(active){
|
|
344
374
|
return this.rowManager.getData(active);
|
|
345
375
|
}
|
|
346
|
-
|
|
376
|
+
|
|
347
377
|
//get table data array count
|
|
348
378
|
getDataCount(active){
|
|
349
379
|
return this.rowManager.getDataCount(active);
|
|
350
380
|
}
|
|
351
|
-
|
|
381
|
+
|
|
352
382
|
//replace data, keeping table in position with same sort
|
|
353
383
|
replaceData(data, params, config){
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
console.warn("replaceData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
|
|
358
|
-
}
|
|
384
|
+
this.initGuard();
|
|
385
|
+
|
|
386
|
+
return this.dataLoader.load(data, params, config, true, true);
|
|
359
387
|
}
|
|
360
|
-
|
|
388
|
+
|
|
361
389
|
//update table data
|
|
362
390
|
updateData(data){
|
|
363
391
|
var responses = 0;
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
console.warn("updateData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
|
|
397
|
-
}
|
|
392
|
+
|
|
393
|
+
this.initGuard();
|
|
394
|
+
|
|
395
|
+
return new Promise((resolve, reject) => {
|
|
396
|
+
this.dataLoader.blockActiveLoad();
|
|
397
|
+
|
|
398
|
+
if(typeof data === "string"){
|
|
399
|
+
data = JSON.parse(data);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if(data){
|
|
403
|
+
data.forEach((item) => {
|
|
404
|
+
var row = this.rowManager.findRow(item[this.options.index]);
|
|
405
|
+
|
|
406
|
+
if(row){
|
|
407
|
+
responses++;
|
|
408
|
+
|
|
409
|
+
row.updateData(item)
|
|
410
|
+
.then(()=>{
|
|
411
|
+
responses--;
|
|
412
|
+
|
|
413
|
+
if(!responses){
|
|
414
|
+
resolve();
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
}else{
|
|
420
|
+
console.warn("Update Error - No data provided");
|
|
421
|
+
reject("Update Error - No data provided");
|
|
422
|
+
}
|
|
423
|
+
});
|
|
398
424
|
}
|
|
399
|
-
|
|
425
|
+
|
|
400
426
|
addData(data, pos, index){
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
resolve(output);
|
|
427
|
+
this.initGuard();
|
|
428
|
+
|
|
429
|
+
return new Promise((resolve, reject) => {
|
|
430
|
+
this.dataLoader.blockActiveLoad();
|
|
431
|
+
|
|
432
|
+
if(typeof data === "string"){
|
|
433
|
+
data = JSON.parse(data);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
if(data){
|
|
437
|
+
this.rowManager.addRows(data, pos, index)
|
|
438
|
+
.then((rows) => {
|
|
439
|
+
var output = [];
|
|
440
|
+
|
|
441
|
+
rows.forEach(function(row){
|
|
442
|
+
output.push(row.getComponent());
|
|
419
443
|
});
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}
|
|
444
|
+
|
|
445
|
+
resolve(output);
|
|
446
|
+
});
|
|
447
|
+
}else{
|
|
448
|
+
console.warn("Update Error - No data provided");
|
|
449
|
+
reject("Update Error - No data provided");
|
|
450
|
+
}
|
|
451
|
+
});
|
|
428
452
|
}
|
|
429
|
-
|
|
453
|
+
|
|
430
454
|
//update table data
|
|
431
455
|
updateOrAddData(data){
|
|
432
456
|
var rows = [],
|
|
433
457
|
responses = 0;
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
console.warn("updateOrAddData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
|
|
478
|
-
}
|
|
458
|
+
|
|
459
|
+
this.initGuard();
|
|
460
|
+
|
|
461
|
+
return new Promise((resolve, reject) => {
|
|
462
|
+
this.dataLoader.blockActiveLoad();
|
|
463
|
+
|
|
464
|
+
if(typeof data === "string"){
|
|
465
|
+
data = JSON.parse(data);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
if(data){
|
|
469
|
+
data.forEach((item) => {
|
|
470
|
+
var row = this.rowManager.findRow(item[this.options.index]);
|
|
471
|
+
|
|
472
|
+
responses++;
|
|
473
|
+
|
|
474
|
+
if(row){
|
|
475
|
+
row.updateData(item)
|
|
476
|
+
.then(()=>{
|
|
477
|
+
responses--;
|
|
478
|
+
rows.push(row.getComponent());
|
|
479
|
+
|
|
480
|
+
if(!responses){
|
|
481
|
+
resolve(rows);
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
}else{
|
|
485
|
+
this.rowManager.addRows(item)
|
|
486
|
+
.then((newRows)=>{
|
|
487
|
+
responses--;
|
|
488
|
+
rows.push(newRows[0].getComponent());
|
|
489
|
+
|
|
490
|
+
if(!responses){
|
|
491
|
+
resolve(rows);
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
}else{
|
|
497
|
+
console.warn("Update Error - No data provided");
|
|
498
|
+
reject("Update Error - No data provided");
|
|
499
|
+
}
|
|
500
|
+
});
|
|
479
501
|
}
|
|
480
|
-
|
|
502
|
+
|
|
481
503
|
//get row object
|
|
482
504
|
getRow(index){
|
|
483
505
|
var row = this.rowManager.findRow(index);
|
|
484
|
-
|
|
506
|
+
|
|
485
507
|
if(row){
|
|
486
508
|
return row.getComponent();
|
|
487
509
|
}else{
|
|
@@ -489,11 +511,11 @@ class Tabulator {
|
|
|
489
511
|
return false;
|
|
490
512
|
}
|
|
491
513
|
}
|
|
492
|
-
|
|
514
|
+
|
|
493
515
|
//get row object
|
|
494
516
|
getRowFromPosition(position, active){
|
|
495
517
|
var row = this.rowManager.getRowFromPosition(position, active);
|
|
496
|
-
|
|
518
|
+
|
|
497
519
|
if(row){
|
|
498
520
|
return row.getComponent();
|
|
499
521
|
}else{
|
|
@@ -501,19 +523,21 @@ class Tabulator {
|
|
|
501
523
|
return false;
|
|
502
524
|
}
|
|
503
525
|
}
|
|
504
|
-
|
|
526
|
+
|
|
505
527
|
//delete row from table
|
|
506
528
|
deleteRow(index){
|
|
507
529
|
var foundRows = [];
|
|
508
|
-
|
|
530
|
+
|
|
531
|
+
this.initGuard();
|
|
532
|
+
|
|
509
533
|
if(!Array.isArray(index)){
|
|
510
534
|
index = [index];
|
|
511
535
|
}
|
|
512
|
-
|
|
536
|
+
|
|
513
537
|
//find matching rows
|
|
514
538
|
for(let item of index){
|
|
515
539
|
let row = this.rowManager.findRow(item, true);
|
|
516
|
-
|
|
540
|
+
|
|
517
541
|
if(row){
|
|
518
542
|
foundRows.push(row);
|
|
519
543
|
}else{
|
|
@@ -522,46 +546,46 @@ class Tabulator {
|
|
|
522
546
|
break;
|
|
523
547
|
}
|
|
524
548
|
}
|
|
525
|
-
|
|
549
|
+
|
|
526
550
|
//sort rows into correct order to ensure smooth delete from table
|
|
527
551
|
foundRows.sort((a, b) => {
|
|
528
552
|
return this.rowManager.rows.indexOf(a) > this.rowManager.rows.indexOf(b) ? 1 : -1;
|
|
529
553
|
});
|
|
530
|
-
|
|
554
|
+
|
|
531
555
|
//delete rows
|
|
532
556
|
foundRows.forEach((row) =>{
|
|
533
557
|
row.delete()
|
|
534
558
|
});
|
|
535
|
-
|
|
559
|
+
|
|
536
560
|
this.rowManager.reRenderInPosition();
|
|
537
|
-
|
|
561
|
+
|
|
538
562
|
return Promise.resolve();
|
|
539
563
|
}
|
|
540
|
-
|
|
564
|
+
|
|
541
565
|
//add row to table
|
|
542
566
|
addRow(data, pos, index){
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
return this.rowManager.addRows(data, pos, index)
|
|
549
|
-
.then((rows)=>{
|
|
550
|
-
return rows[0].getComponent();
|
|
551
|
-
});
|
|
552
|
-
}else{
|
|
553
|
-
console.warn("addRow failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
|
|
567
|
+
this.initGuard();
|
|
568
|
+
|
|
569
|
+
if(typeof data === "string"){
|
|
570
|
+
data = JSON.parse(data);
|
|
554
571
|
}
|
|
572
|
+
|
|
573
|
+
return this.rowManager.addRows(data, pos, index)
|
|
574
|
+
.then((rows)=>{
|
|
575
|
+
return rows[0].getComponent();
|
|
576
|
+
});
|
|
555
577
|
}
|
|
556
|
-
|
|
578
|
+
|
|
557
579
|
//update a row if it exitsts otherwise create it
|
|
558
580
|
updateOrAddRow(index, data){
|
|
559
581
|
var row = this.rowManager.findRow(index);
|
|
560
|
-
|
|
582
|
+
|
|
583
|
+
this.initGuard();
|
|
584
|
+
|
|
561
585
|
if(typeof data === "string"){
|
|
562
586
|
data = JSON.parse(data);
|
|
563
587
|
}
|
|
564
|
-
|
|
588
|
+
|
|
565
589
|
if(row){
|
|
566
590
|
return row.updateData(data)
|
|
567
591
|
.then(()=>{
|
|
@@ -574,15 +598,17 @@ class Tabulator {
|
|
|
574
598
|
})
|
|
575
599
|
}
|
|
576
600
|
}
|
|
577
|
-
|
|
601
|
+
|
|
578
602
|
//update row data
|
|
579
603
|
updateRow(index, data){
|
|
580
604
|
var row = this.rowManager.findRow(index);
|
|
581
|
-
|
|
605
|
+
|
|
606
|
+
this.initGuard();
|
|
607
|
+
|
|
582
608
|
if(typeof data === "string"){
|
|
583
609
|
data = JSON.parse(data);
|
|
584
610
|
}
|
|
585
|
-
|
|
611
|
+
|
|
586
612
|
if(row){
|
|
587
613
|
return row.updateData(data)
|
|
588
614
|
.then(()=>{
|
|
@@ -593,11 +619,11 @@ class Tabulator {
|
|
|
593
619
|
return Promise.reject("Update Error - No matching row found");
|
|
594
620
|
}
|
|
595
621
|
}
|
|
596
|
-
|
|
622
|
+
|
|
597
623
|
//scroll to row in DOM
|
|
598
624
|
scrollToRow(index, position, ifVisible){
|
|
599
625
|
var row = this.rowManager.findRow(index);
|
|
600
|
-
|
|
626
|
+
|
|
601
627
|
if(row){
|
|
602
628
|
return this.rowManager.scrollToRow(row, position, ifVisible)
|
|
603
629
|
}else{
|
|
@@ -605,25 +631,27 @@ class Tabulator {
|
|
|
605
631
|
return Promise.reject("Scroll Error - No matching row found");
|
|
606
632
|
}
|
|
607
633
|
}
|
|
608
|
-
|
|
634
|
+
|
|
609
635
|
moveRow(from, to, after){
|
|
610
636
|
var fromRow = this.rowManager.findRow(from);
|
|
611
|
-
|
|
637
|
+
|
|
638
|
+
this.initGuard();
|
|
639
|
+
|
|
612
640
|
if(fromRow){
|
|
613
641
|
fromRow.moveToRow(to, after);
|
|
614
642
|
}else{
|
|
615
643
|
console.warn("Move Error - No matching row found:", from);
|
|
616
644
|
}
|
|
617
645
|
}
|
|
618
|
-
|
|
646
|
+
|
|
619
647
|
getRows(active){
|
|
620
|
-
return this.rowManager.getComponents(active);
|
|
648
|
+
return this.rowManager.getComponents(active);
|
|
621
649
|
}
|
|
622
|
-
|
|
650
|
+
|
|
623
651
|
//get position of row in table
|
|
624
652
|
getRowPosition(index, active){
|
|
625
653
|
var row = this.rowManager.findRow(index);
|
|
626
|
-
|
|
654
|
+
|
|
627
655
|
if(row){
|
|
628
656
|
return this.rowManager.getRowPosition(row, active);
|
|
629
657
|
}else{
|
|
@@ -631,38 +659,38 @@ class Tabulator {
|
|
|
631
659
|
return false;
|
|
632
660
|
}
|
|
633
661
|
}
|
|
634
|
-
|
|
662
|
+
|
|
635
663
|
/////////////// Column Functions ///////////////
|
|
636
664
|
setColumns(definition){
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
console.warn("setColumns failed - table not yet initialized. To set initial data please use the 'columns' property in the table constructor.")
|
|
641
|
-
}
|
|
665
|
+
this.initGuard(false, "To set initial columns please use the 'columns' property in the table constructor");
|
|
666
|
+
|
|
667
|
+
this.columnManager.setColumns(definition);
|
|
642
668
|
}
|
|
643
|
-
|
|
669
|
+
|
|
644
670
|
getColumns(structured){
|
|
645
671
|
return this.columnManager.getComponents(structured);
|
|
646
672
|
}
|
|
647
|
-
|
|
673
|
+
|
|
648
674
|
getColumn(field){
|
|
649
|
-
var
|
|
650
|
-
|
|
651
|
-
if(
|
|
652
|
-
return
|
|
675
|
+
var column = this.columnManager.findColumn(field);
|
|
676
|
+
|
|
677
|
+
if(column){
|
|
678
|
+
return column.getComponent();
|
|
653
679
|
}else{
|
|
654
680
|
console.warn("Find Error - No matching column found:", field);
|
|
655
681
|
return false;
|
|
656
682
|
}
|
|
657
683
|
}
|
|
658
|
-
|
|
684
|
+
|
|
659
685
|
getColumnDefinitions(){
|
|
660
686
|
return this.columnManager.getDefinitionTree();
|
|
661
687
|
}
|
|
662
|
-
|
|
688
|
+
|
|
663
689
|
showColumn(field){
|
|
664
690
|
var column = this.columnManager.findColumn(field);
|
|
665
|
-
|
|
691
|
+
|
|
692
|
+
this.initGuard();
|
|
693
|
+
|
|
666
694
|
if(column){
|
|
667
695
|
column.show();
|
|
668
696
|
}else{
|
|
@@ -670,10 +698,12 @@ class Tabulator {
|
|
|
670
698
|
return false;
|
|
671
699
|
}
|
|
672
700
|
}
|
|
673
|
-
|
|
701
|
+
|
|
674
702
|
hideColumn(field){
|
|
675
|
-
var column = this.columnManager.findColumn(field);
|
|
676
|
-
|
|
703
|
+
var column = this.columnManager.findColumn(field);
|
|
704
|
+
|
|
705
|
+
this.initGuard();
|
|
706
|
+
|
|
677
707
|
if(column){
|
|
678
708
|
column.hide();
|
|
679
709
|
}else{
|
|
@@ -681,10 +711,12 @@ class Tabulator {
|
|
|
681
711
|
return false;
|
|
682
712
|
}
|
|
683
713
|
}
|
|
684
|
-
|
|
714
|
+
|
|
685
715
|
toggleColumn(field){
|
|
686
716
|
var column = this.columnManager.findColumn(field);
|
|
687
|
-
|
|
717
|
+
|
|
718
|
+
this.initGuard();
|
|
719
|
+
|
|
688
720
|
if(column){
|
|
689
721
|
if(column.visible){
|
|
690
722
|
column.hide();
|
|
@@ -696,19 +728,23 @@ class Tabulator {
|
|
|
696
728
|
return false;
|
|
697
729
|
}
|
|
698
730
|
}
|
|
699
|
-
|
|
731
|
+
|
|
700
732
|
addColumn(definition, before, field){
|
|
701
733
|
var column = this.columnManager.findColumn(field);
|
|
702
|
-
|
|
734
|
+
|
|
735
|
+
this.initGuard();
|
|
736
|
+
|
|
703
737
|
return this.columnManager.addColumn(definition, before, column)
|
|
704
738
|
.then((column) => {
|
|
705
739
|
return column.getComponent();
|
|
706
740
|
});
|
|
707
741
|
}
|
|
708
|
-
|
|
742
|
+
|
|
709
743
|
deleteColumn(field){
|
|
710
744
|
var column = this.columnManager.findColumn(field);
|
|
711
|
-
|
|
745
|
+
|
|
746
|
+
this.initGuard();
|
|
747
|
+
|
|
712
748
|
if(column){
|
|
713
749
|
return column.delete();
|
|
714
750
|
}else{
|
|
@@ -716,10 +752,12 @@ class Tabulator {
|
|
|
716
752
|
return Promise.reject();
|
|
717
753
|
}
|
|
718
754
|
}
|
|
719
|
-
|
|
755
|
+
|
|
720
756
|
updateColumnDefinition(field, definition){
|
|
721
757
|
var column = this.columnManager.findColumn(field);
|
|
722
|
-
|
|
758
|
+
|
|
759
|
+
this.initGuard();
|
|
760
|
+
|
|
723
761
|
if(column){
|
|
724
762
|
return column.updateDefinition(definition)
|
|
725
763
|
}else{
|
|
@@ -727,11 +765,13 @@ class Tabulator {
|
|
|
727
765
|
return Promise.reject();
|
|
728
766
|
}
|
|
729
767
|
}
|
|
730
|
-
|
|
768
|
+
|
|
731
769
|
moveColumn(from, to, after){
|
|
732
|
-
var fromColumn = this.columnManager.findColumn(from)
|
|
733
|
-
|
|
734
|
-
|
|
770
|
+
var fromColumn = this.columnManager.findColumn(from),
|
|
771
|
+
toColumn = this.columnManager.findColumn(to);
|
|
772
|
+
|
|
773
|
+
this.initGuard();
|
|
774
|
+
|
|
735
775
|
if(fromColumn){
|
|
736
776
|
if(toColumn){
|
|
737
777
|
this.columnManager.moveColumn(fromColumn, toColumn, after)
|
|
@@ -742,12 +782,12 @@ class Tabulator {
|
|
|
742
782
|
console.warn("Move Error - No matching column found:", from);
|
|
743
783
|
}
|
|
744
784
|
}
|
|
745
|
-
|
|
785
|
+
|
|
746
786
|
//scroll to column in DOM
|
|
747
787
|
scrollToColumn(field, position, ifVisible){
|
|
748
788
|
return new Promise((resolve, reject) => {
|
|
749
789
|
var column = this.columnManager.findColumn(field);
|
|
750
|
-
|
|
790
|
+
|
|
751
791
|
if(column){
|
|
752
792
|
return this.columnManager.scrollToColumn(column, position, ifVisible)
|
|
753
793
|
}else{
|
|
@@ -756,42 +796,54 @@ class Tabulator {
|
|
|
756
796
|
}
|
|
757
797
|
});
|
|
758
798
|
}
|
|
759
|
-
|
|
799
|
+
|
|
760
800
|
//////////// General Public Functions ////////////
|
|
761
801
|
//redraw list without updating data
|
|
762
802
|
redraw(force){
|
|
763
|
-
|
|
764
|
-
this.columnManager.redraw(force);
|
|
765
|
-
this.rowManager.redraw(force);
|
|
766
|
-
}else{
|
|
767
|
-
console.warn("redraw failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
|
|
768
|
-
}
|
|
769
|
-
}
|
|
803
|
+
this.initGuard();
|
|
770
804
|
|
|
805
|
+
this.columnManager.redraw(force);
|
|
806
|
+
this.rowManager.redraw(force);
|
|
807
|
+
}
|
|
808
|
+
|
|
771
809
|
setHeight(height){
|
|
772
810
|
this.options.height = isNaN(height) ? height : height + "px";
|
|
773
811
|
this.element.style.height = this.options.height;
|
|
774
812
|
this.rowManager.initializeRenderer();
|
|
775
813
|
this.rowManager.redraw();
|
|
776
814
|
}
|
|
777
|
-
|
|
815
|
+
|
|
778
816
|
//////////////////// Event Bus ///////////////////
|
|
779
|
-
|
|
817
|
+
|
|
780
818
|
on(key, callback){
|
|
781
819
|
this.externalEvents.subscribe(key, callback);
|
|
782
820
|
}
|
|
783
|
-
|
|
821
|
+
|
|
784
822
|
off(key, callback){
|
|
785
823
|
this.externalEvents.unsubscribe(key, callback);
|
|
786
824
|
}
|
|
787
|
-
|
|
825
|
+
|
|
788
826
|
dispatchEvent(){
|
|
789
827
|
var args = Array.from(arguments),
|
|
790
828
|
key = args.shift();
|
|
791
|
-
|
|
829
|
+
|
|
792
830
|
this.externalEvents.dispatch(...arguments)
|
|
793
831
|
}
|
|
794
832
|
|
|
833
|
+
//////////////////// Alerts ///////////////////
|
|
834
|
+
|
|
835
|
+
alert(contents, type){
|
|
836
|
+
this.initGuard();
|
|
837
|
+
|
|
838
|
+
this.alertManager.alert(contents, type);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
clearAlert(){
|
|
842
|
+
this.initGuard();
|
|
843
|
+
|
|
844
|
+
this.alertManager.clear();
|
|
845
|
+
}
|
|
846
|
+
|
|
795
847
|
////////////// Extension Management //////////////
|
|
796
848
|
modExists(plugin, required){
|
|
797
849
|
if(this.modules[plugin]){
|
|
@@ -803,14 +855,14 @@ class Tabulator {
|
|
|
803
855
|
return false;
|
|
804
856
|
}
|
|
805
857
|
}
|
|
806
|
-
|
|
858
|
+
|
|
807
859
|
module(key){
|
|
808
860
|
var mod = this.modules[key];
|
|
809
|
-
|
|
861
|
+
|
|
810
862
|
if(!mod){
|
|
811
863
|
console.error("Tabulator module not installed: " + key);
|
|
812
864
|
}
|
|
813
|
-
|
|
865
|
+
|
|
814
866
|
return mod;
|
|
815
867
|
}
|
|
816
868
|
}
|