tabulator-tables 6.5.0 → 6.5.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/dist/js/tabulator.js +1 -1
- package/dist/js/tabulator.min.js +1 -1
- package/dist/js/tabulator_esm.js +1 -1
- package/dist/js/tabulator_esm.min.js +1 -1
- package/dist/js/tabulator_esm.min.mjs +1 -1
- package/dist/js/tabulator_esm.mjs +1 -1
- package/package.json +2 -1
- package/src/js/builds/esm.js +16 -0
- package/src/js/builds/jquery_wrapper.js +63 -0
- package/src/js/builds/usd.js +1 -0
- package/src/js/core/ColumnManager.js +789 -0
- package/src/js/core/CoreFeature.js +140 -0
- package/src/js/core/FooterManager.js +102 -0
- package/src/js/core/Module.js +140 -0
- package/src/js/core/RowManager.js +1140 -0
- package/src/js/core/Tabulator.js +928 -0
- package/src/js/core/TabulatorFull.js +21 -0
- package/src/js/core/cell/Cell.js +299 -0
- package/src/js/core/cell/CellComponent.js +79 -0
- package/src/js/core/column/Column.js +978 -0
- package/src/js/core/column/ColumnComponent.js +151 -0
- package/src/js/core/column/defaults/options.js +18 -0
- package/src/js/core/defaults/options.js +66 -0
- package/src/js/core/modules/core.js +3 -0
- package/src/js/core/modules/optional.js +37 -0
- package/src/js/core/rendering/Renderer.js +204 -0
- package/src/js/core/rendering/renderers/BasicHorizontal.js +27 -0
- package/src/js/core/rendering/renderers/BasicVertical.js +103 -0
- package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +587 -0
- package/src/js/core/rendering/renderers/VirtualDomVertical.js +642 -0
- package/src/js/core/row/PseudoRow.js +47 -0
- package/src/js/core/row/Row.js +487 -0
- package/src/js/core/row/RowComponent.js +94 -0
- package/src/js/core/tools/Alert.js +66 -0
- package/src/js/core/tools/ComponentFunctionBinder.js +32 -0
- package/src/js/core/tools/DataLoader.js +128 -0
- package/src/js/core/tools/DependencyRegistry.js +82 -0
- package/src/js/core/tools/DeprecationAdvisor.js +51 -0
- package/src/js/core/tools/ExternalEventBus.js +105 -0
- package/src/js/core/tools/Helpers.js +66 -0
- package/src/js/core/tools/InteractionMonitor.js +329 -0
- package/src/js/core/tools/InternalEventBus.js +162 -0
- package/src/js/core/tools/ModuleBinder.js +153 -0
- package/src/js/core/tools/OptionsList.js +45 -0
- package/src/js/core/tools/Popup.js +317 -0
- package/src/js/core/tools/TableRegistry.js +65 -0
- package/src/js/modules/Accessor/Accessor.js +115 -0
- package/src/js/modules/Accessor/defaults/accessors.js +5 -0
- package/src/js/modules/Ajax/Ajax.js +142 -0
- package/src/js/modules/Ajax/defaults/config.js +3 -0
- package/src/js/modules/Ajax/defaults/contentTypeFormatters.js +45 -0
- package/src/js/modules/Ajax/defaults/loaderPromise.js +87 -0
- package/src/js/modules/Ajax/defaults/urlGenerator.js +44 -0
- package/src/js/modules/Clipboard/Clipboard.js +282 -0
- package/src/js/modules/Clipboard/defaults/pasteActions.js +11 -0
- package/src/js/modules/Clipboard/defaults/pasteParsers.js +75 -0
- package/src/js/modules/Clipboard/extensions/extensions.js +9 -0
- package/src/js/modules/Clipboard/extensions/keybindings/actions.js +9 -0
- package/src/js/modules/Clipboard/extensions/keybindings/bindings.js +3 -0
- package/src/js/modules/ColumnCalcs/CalcComponent.js +46 -0
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +586 -0
- package/src/js/modules/ColumnCalcs/defaults/calculations.js +93 -0
- package/src/js/modules/Comms/Comms.js +49 -0
- package/src/js/modules/DataTree/DataTree.js +620 -0
- package/src/js/modules/Download/Download.js +146 -0
- package/src/js/modules/Download/defaults/downloaders/csv.js +61 -0
- package/src/js/modules/Download/defaults/downloaders/html.js +5 -0
- package/src/js/modules/Download/defaults/downloaders/json.js +34 -0
- package/src/js/modules/Download/defaults/downloaders/jsonLines.js +32 -0
- package/src/js/modules/Download/defaults/downloaders/pdf.js +113 -0
- package/src/js/modules/Download/defaults/downloaders/xlsx.js +103 -0
- package/src/js/modules/Download/defaults/downloaders.js +15 -0
- package/src/js/modules/Edit/Edit.js +845 -0
- package/src/js/modules/Edit/List.js +1060 -0
- package/src/js/modules/Edit/defaults/editors/adaptable.js +37 -0
- package/src/js/modules/Edit/defaults/editors/date.js +144 -0
- package/src/js/modules/Edit/defaults/editors/datetime.js +131 -0
- package/src/js/modules/Edit/defaults/editors/input.js +77 -0
- package/src/js/modules/Edit/defaults/editors/list.js +7 -0
- package/src/js/modules/Edit/defaults/editors/number.js +110 -0
- package/src/js/modules/Edit/defaults/editors/progress.js +127 -0
- package/src/js/modules/Edit/defaults/editors/range.js +81 -0
- package/src/js/modules/Edit/defaults/editors/star.js +146 -0
- package/src/js/modules/Edit/defaults/editors/textarea.js +123 -0
- package/src/js/modules/Edit/defaults/editors/tickCross.js +95 -0
- package/src/js/modules/Edit/defaults/editors/time.js +132 -0
- package/src/js/modules/Edit/defaults/editors.js +27 -0
- package/src/js/modules/Edit/inputMask.js +74 -0
- package/src/js/modules/Export/Export.js +654 -0
- package/src/js/modules/Export/ExportColumn.js +9 -0
- package/src/js/modules/Export/ExportRow.js +8 -0
- package/src/js/modules/Export/defaults/columnLookups.js +3 -0
- package/src/js/modules/Export/defaults/rowLookups.js +18 -0
- package/src/js/modules/Filter/Filter.js +902 -0
- package/src/js/modules/Filter/defaults/filters.js +215 -0
- package/src/js/modules/Format/Format.js +200 -0
- package/src/js/modules/Format/defaults/formatters/adaptable.js +32 -0
- package/src/js/modules/Format/defaults/formatters/array.js +30 -0
- package/src/js/modules/Format/defaults/formatters/buttonCross.js +3 -0
- package/src/js/modules/Format/defaults/formatters/buttonTick.js +3 -0
- package/src/js/modules/Format/defaults/formatters/color.js +4 -0
- package/src/js/modules/Format/defaults/formatters/datetime.js +39 -0
- package/src/js/modules/Format/defaults/formatters/datetimediff.js +43 -0
- package/src/js/modules/Format/defaults/formatters/handle.js +4 -0
- package/src/js/modules/Format/defaults/formatters/html.js +3 -0
- package/src/js/modules/Format/defaults/formatters/image.js +40 -0
- package/src/js/modules/Format/defaults/formatters/json.js +12 -0
- package/src/js/modules/Format/defaults/formatters/link.js +82 -0
- package/src/js/modules/Format/defaults/formatters/lookup.js +10 -0
- package/src/js/modules/Format/defaults/formatters/money.js +44 -0
- package/src/js/modules/Format/defaults/formatters/plaintext.js +3 -0
- package/src/js/modules/Format/defaults/formatters/progress.js +133 -0
- package/src/js/modules/Format/defaults/formatters/rownum.js +14 -0
- package/src/js/modules/Format/defaults/formatters/star.js +38 -0
- package/src/js/modules/Format/defaults/formatters/textarea.js +4 -0
- package/src/js/modules/Format/defaults/formatters/tickCross.js +22 -0
- package/src/js/modules/Format/defaults/formatters/toggle.js +48 -0
- package/src/js/modules/Format/defaults/formatters/traffic.js +47 -0
- package/src/js/modules/Format/defaults/formatters.js +47 -0
- package/src/js/modules/FrozenColumns/FrozenColumns.js +302 -0
- package/src/js/modules/FrozenRows/FrozenRows.js +175 -0
- package/src/js/modules/GroupRows/Group.js +615 -0
- package/src/js/modules/GroupRows/GroupComponent.js +69 -0
- package/src/js/modules/GroupRows/GroupRows.js +636 -0
- package/src/js/modules/History/History.js +172 -0
- package/src/js/modules/History/defaults/redoers.js +31 -0
- package/src/js/modules/History/defaults/undoers.js +33 -0
- package/src/js/modules/History/extensions/extensions.js +9 -0
- package/src/js/modules/History/extensions/keybindings/actions.js +27 -0
- package/src/js/modules/History/extensions/keybindings/bindings.js +4 -0
- package/src/js/modules/HtmlTableImport/HtmlTableImport.js +180 -0
- package/src/js/modules/Import/Import.js +303 -0
- package/src/js/modules/Import/defaults/importers/array.js +3 -0
- package/src/js/modules/Import/defaults/importers/csv.js +61 -0
- package/src/js/modules/Import/defaults/importers/json.js +8 -0
- package/src/js/modules/Import/defaults/importers/xlsx.js +7 -0
- package/src/js/modules/Import/defaults/importers.js +11 -0
- package/src/js/modules/Interaction/Interaction.js +339 -0
- package/src/js/modules/Keybindings/Keybindings.js +198 -0
- package/src/js/modules/Keybindings/defaults/actions.js +90 -0
- package/src/js/modules/Keybindings/defaults/bindings.js +12 -0
- package/src/js/modules/Layout/Layout.js +66 -0
- package/src/js/modules/Layout/defaults/modes/fitColumns.js +171 -0
- package/src/js/modules/Layout/defaults/modes/fitData.js +10 -0
- package/src/js/modules/Layout/defaults/modes/fitDataGeneral.js +10 -0
- package/src/js/modules/Layout/defaults/modes/fitDataStretch.js +40 -0
- package/src/js/modules/Layout/defaults/modes.js +12 -0
- package/src/js/modules/Localize/Localize.js +184 -0
- package/src/js/modules/Localize/defaults/langs.js +37 -0
- package/src/js/modules/Menu/Menu.js +302 -0
- package/src/js/modules/MoveColumns/MoveColumns.js +311 -0
- package/src/js/modules/MoveRows/MoveRows.js +604 -0
- package/src/js/modules/MoveRows/defaults/receivers.js +30 -0
- package/src/js/modules/MoveRows/defaults/senders.js +5 -0
- package/src/js/modules/Mutator/Mutator.js +164 -0
- package/src/js/modules/Mutator/defaults/mutators.js +1 -0
- package/src/js/modules/Page/Page.js +891 -0
- package/src/js/modules/Page/defaults/pageCounters/pages.js +33 -0
- package/src/js/modules/Page/defaults/pageCounters/rows.js +40 -0
- package/src/js/modules/Page/defaults/pageCounters.js +8 -0
- package/src/js/modules/Persistence/Persistence.js +473 -0
- package/src/js/modules/Persistence/defaults/readers.js +29 -0
- package/src/js/modules/Persistence/defaults/writers.js +13 -0
- package/src/js/modules/Popup/Popup.js +227 -0
- package/src/js/modules/Print/Print.js +136 -0
- package/src/js/modules/ReactiveData/ReactiveData.js +416 -0
- package/src/js/modules/ResizeColumns/ResizeColumns.js +365 -0
- package/src/js/modules/ResizeRows/ResizeRows.js +145 -0
- package/src/js/modules/ResizeTable/ResizeTable.js +158 -0
- package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +354 -0
- package/src/js/modules/ResponsiveLayout/extensions/extensions.js +9 -0
- package/src/js/modules/ResponsiveLayout/extensions/formatters/responsiveCollapse.js +44 -0
- package/src/js/modules/SelectRange/Range.js +366 -0
- package/src/js/modules/SelectRange/RangeComponent.js +91 -0
- package/src/js/modules/SelectRange/SelectRange.js +993 -0
- package/src/js/modules/SelectRange/extensions/clipboard/pasteActions.js +45 -0
- package/src/js/modules/SelectRange/extensions/clipboard/pasteParsers.js +57 -0
- package/src/js/modules/SelectRange/extensions/export/columnLookups.js +11 -0
- package/src/js/modules/SelectRange/extensions/export/rowLookups.js +5 -0
- package/src/js/modules/SelectRange/extensions/extensions.js +21 -0
- package/src/js/modules/SelectRange/extensions/keybindings/actions.js +38 -0
- package/src/js/modules/SelectRange/extensions/keybindings/bindings.js +14 -0
- package/src/js/modules/SelectRow/SelectRow.js +499 -0
- package/src/js/modules/SelectRow/extensions/extensions.js +9 -0
- package/src/js/modules/SelectRow/extensions/formatters/rowSelection.js +60 -0
- package/src/js/modules/Sort/Sort.js +480 -0
- package/src/js/modules/Sort/defaults/sorters/alphanum.js +44 -0
- package/src/js/modules/Sort/defaults/sorters/array.js +82 -0
- package/src/js/modules/Sort/defaults/sorters/boolean.js +7 -0
- package/src/js/modules/Sort/defaults/sorters/date.js +10 -0
- package/src/js/modules/Sort/defaults/sorters/datetime.js +48 -0
- package/src/js/modules/Sort/defaults/sorters/exists.js +7 -0
- package/src/js/modules/Sort/defaults/sorters/number.js +40 -0
- package/src/js/modules/Sort/defaults/sorters/string.js +34 -0
- package/src/js/modules/Sort/defaults/sorters/time.js +10 -0
- package/src/js/modules/Sort/defaults/sorters.js +21 -0
- package/src/js/modules/Spreadsheet/GridCalculator.js +64 -0
- package/src/js/modules/Spreadsheet/Sheet.js +243 -0
- package/src/js/modules/Spreadsheet/SheetComponent.js +59 -0
- package/src/js/modules/Spreadsheet/Spreadsheet.js +309 -0
- package/src/js/modules/Tooltip/Tooltip.js +128 -0
- package/src/js/modules/Validate/Validate.js +303 -0
- package/src/js/modules/Validate/defaults/validators.js +150 -0
- package/src/scss/tabulator.scss +1693 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +302 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +589 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +979 -0
- package/src/scss/themes/bootstrap/variables3.scss +872 -0
- package/src/scss/themes/bootstrap/variables4.scss +1059 -0
- package/src/scss/themes/bootstrap/variables5.scss +1967 -0
- package/src/scss/themes/bulma/tabulator_bulma.scss +316 -0
- package/src/scss/themes/bulma/variables.scss +198 -0
- package/src/scss/themes/materialize/tabulator_materialize.scss +318 -0
- package/src/scss/themes/materialize/variables.scss +71 -0
- package/src/scss/themes/semanticui/tabulator_semanticui.scss +623 -0
- package/src/scss/themes/semanticui/variables.scss +843 -0
- package/src/scss/themes/semanticui/variables_table.scss +248 -0
- package/src/scss/themes/tabulator_midnight.scss +235 -0
- package/src/scss/themes/tabulator_modern.scss +308 -0
- package/src/scss/themes/tabulator_simple.scss +143 -0
- package/src/scss/themes/tabulator_site.scss +267 -0
- package/src/scss/themes/tabulator_site_dark.scss +496 -0
|
@@ -0,0 +1,928 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import defaultOptions from './defaults/options.js';
|
|
4
|
+
|
|
5
|
+
import ColumnManager from './ColumnManager.js';
|
|
6
|
+
import RowManager from './RowManager.js';
|
|
7
|
+
import FooterManager from './FooterManager.js';
|
|
8
|
+
|
|
9
|
+
import InteractionMonitor from './tools/InteractionMonitor.js';
|
|
10
|
+
import ComponentFunctionBinder from './tools/ComponentFunctionBinder.js';
|
|
11
|
+
import DataLoader from './tools/DataLoader.js';
|
|
12
|
+
|
|
13
|
+
import ExternalEventBus from './tools/ExternalEventBus.js';
|
|
14
|
+
import InternalEventBus from './tools/InternalEventBus.js';
|
|
15
|
+
|
|
16
|
+
import DeprecationAdvisor from './tools/DeprecationAdvisor.js';
|
|
17
|
+
import DependencyRegistry from './tools/DependencyRegistry.js';
|
|
18
|
+
|
|
19
|
+
import ModuleBinder from './tools/ModuleBinder.js';
|
|
20
|
+
|
|
21
|
+
import OptionsList from './tools/OptionsList.js';
|
|
22
|
+
|
|
23
|
+
import Alert from './tools/Alert.js';
|
|
24
|
+
|
|
25
|
+
class Tabulator extends ModuleBinder{
|
|
26
|
+
|
|
27
|
+
//default setup options
|
|
28
|
+
static defaultOptions = defaultOptions;
|
|
29
|
+
|
|
30
|
+
static extendModule(){
|
|
31
|
+
Tabulator.initializeModuleBinder();
|
|
32
|
+
Tabulator._extendModule(...arguments);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static registerModule(){
|
|
36
|
+
Tabulator.initializeModuleBinder();
|
|
37
|
+
Tabulator._registerModule(...arguments);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
constructor(element, options, modules){
|
|
41
|
+
super();
|
|
42
|
+
|
|
43
|
+
Tabulator.initializeModuleBinder(modules);
|
|
44
|
+
|
|
45
|
+
this.options = {};
|
|
46
|
+
|
|
47
|
+
this.columnManager = null; // hold Column Manager
|
|
48
|
+
this.rowManager = null; //hold Row Manager
|
|
49
|
+
this.footerManager = null; //holder Footer Manager
|
|
50
|
+
this.alertManager = null; //hold Alert Manager
|
|
51
|
+
this.vdomHoz = null; //holder horizontal virtual dom
|
|
52
|
+
this.externalEvents = null; //handle external event messaging
|
|
53
|
+
this.eventBus = null; //handle internal event messaging
|
|
54
|
+
this.interactionMonitor = false; //track user interaction
|
|
55
|
+
this.browser = ""; //hold current browser type
|
|
56
|
+
this.browserSlow = false; //handle reduced functionality for slower browsers
|
|
57
|
+
this.browserMobile = false; //check if running on mobile, prevent resize cancelling edit on keyboard appearance
|
|
58
|
+
this.rtl = false; //check if the table is in RTL mode
|
|
59
|
+
this.originalElement = null; //hold original table element if it has been replaced
|
|
60
|
+
|
|
61
|
+
this.componentFunctionBinder = new ComponentFunctionBinder(this); //bind component functions
|
|
62
|
+
this.dataLoader = false; //bind component functions
|
|
63
|
+
|
|
64
|
+
this.modules = {}; //hold all modules bound to this table
|
|
65
|
+
this.modulesCore = []; //hold core modules bound to this table (for initialization purposes)
|
|
66
|
+
this.modulesRegular = []; //hold regular modules bound to this table (for initialization purposes)
|
|
67
|
+
|
|
68
|
+
this.deprecationAdvisor = new DeprecationAdvisor(this);
|
|
69
|
+
this.optionsList = new OptionsList(this, "table constructor");
|
|
70
|
+
|
|
71
|
+
this.dependencyRegistry = new DependencyRegistry(this);
|
|
72
|
+
|
|
73
|
+
this.initialized = false;
|
|
74
|
+
this.destroyed = false;
|
|
75
|
+
|
|
76
|
+
if(this.initializeElement(element)){
|
|
77
|
+
|
|
78
|
+
this.initializeCoreSystems(options);
|
|
79
|
+
|
|
80
|
+
//delay table creation to allow event bindings immediately after the constructor
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
this._create();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.constructor.registry.register(this); //register table for inter-device communication
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
initializeElement(element){
|
|
90
|
+
if(typeof HTMLElement !== "undefined" && element instanceof HTMLElement){
|
|
91
|
+
this.element = element;
|
|
92
|
+
return true;
|
|
93
|
+
}else if(typeof element === "string"){
|
|
94
|
+
this.element = document.querySelector(element);
|
|
95
|
+
|
|
96
|
+
if(this.element){
|
|
97
|
+
return true;
|
|
98
|
+
}else{
|
|
99
|
+
console.error("Tabulator Creation Error - no element found matching selector: ", element);
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}else{
|
|
103
|
+
console.error("Tabulator Creation Error - Invalid element provided:", element);
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
initializeCoreSystems(options){
|
|
109
|
+
this.columnManager = new ColumnManager(this);
|
|
110
|
+
this.rowManager = new RowManager(this);
|
|
111
|
+
this.footerManager = new FooterManager(this);
|
|
112
|
+
this.dataLoader = new DataLoader(this);
|
|
113
|
+
this.alertManager = new Alert(this);
|
|
114
|
+
|
|
115
|
+
this._bindModules();
|
|
116
|
+
|
|
117
|
+
this.options = this.optionsList.generate(Tabulator.defaultOptions, options);
|
|
118
|
+
|
|
119
|
+
this._clearObjectPointers();
|
|
120
|
+
|
|
121
|
+
this._mapDeprecatedFunctionality();
|
|
122
|
+
|
|
123
|
+
this.externalEvents = new ExternalEventBus(this, this.options, this.options.debugEventsExternal);
|
|
124
|
+
this.eventBus = new InternalEventBus(this.options.debugEventsInternal);
|
|
125
|
+
|
|
126
|
+
this.interactionMonitor = new InteractionMonitor(this);
|
|
127
|
+
|
|
128
|
+
this.dataLoader.initialize();
|
|
129
|
+
this.footerManager.initialize();
|
|
130
|
+
|
|
131
|
+
this.dependencyRegistry.initialize();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//convert deprecated functionality to new functions
|
|
135
|
+
_mapDeprecatedFunctionality(){
|
|
136
|
+
//all previously deprecated functionality removed in the 6.0 release
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
_clearSelection(){
|
|
140
|
+
|
|
141
|
+
this.element.classList.add("tabulator-block-select");
|
|
142
|
+
|
|
143
|
+
if (window.getSelection) {
|
|
144
|
+
if (window.getSelection().empty) { // Chrome
|
|
145
|
+
window.getSelection().empty();
|
|
146
|
+
} else if (window.getSelection().removeAllRanges) { // Firefox
|
|
147
|
+
window.getSelection().removeAllRanges();
|
|
148
|
+
}
|
|
149
|
+
} else if (document.selection) { // IE?
|
|
150
|
+
document.selection.empty();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
this.element.classList.remove("tabulator-block-select");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
//create table
|
|
157
|
+
_create(){
|
|
158
|
+
this.externalEvents.dispatch("tableBuilding");
|
|
159
|
+
this.eventBus.dispatch("table-building");
|
|
160
|
+
|
|
161
|
+
this._rtlCheck();
|
|
162
|
+
|
|
163
|
+
this._buildElement();
|
|
164
|
+
|
|
165
|
+
this._initializeTable();
|
|
166
|
+
|
|
167
|
+
this.initialized = true;
|
|
168
|
+
|
|
169
|
+
this._loadInitialData()
|
|
170
|
+
.finally(() => {
|
|
171
|
+
this.eventBus.dispatch("table-initialized");
|
|
172
|
+
this.externalEvents.dispatch("tableBuilt");
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
_rtlCheck(){
|
|
177
|
+
var style = window.getComputedStyle(this.element);
|
|
178
|
+
|
|
179
|
+
switch(this.options.textDirection){
|
|
180
|
+
case"auto":
|
|
181
|
+
if(style.direction !== "rtl"){
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
case "rtl":
|
|
186
|
+
this.element.classList.add("tabulator-rtl");
|
|
187
|
+
this.rtl = true;
|
|
188
|
+
break;
|
|
189
|
+
|
|
190
|
+
case "ltr":
|
|
191
|
+
this.element.classList.add("tabulator-ltr");
|
|
192
|
+
|
|
193
|
+
default:
|
|
194
|
+
this.rtl = false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
//clear pointers to objects in default config object
|
|
199
|
+
_clearObjectPointers(){
|
|
200
|
+
this.options.columns = this.options.columns.slice(0);
|
|
201
|
+
|
|
202
|
+
if(Array.isArray(this.options.data) && !this.options.reactiveData){
|
|
203
|
+
this.options.data = this.options.data.slice(0);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//build tabulator element
|
|
208
|
+
_buildElement(){
|
|
209
|
+
var element = this.element,
|
|
210
|
+
options = this.options,
|
|
211
|
+
newElement;
|
|
212
|
+
|
|
213
|
+
if(element.tagName === "TABLE"){
|
|
214
|
+
this.originalElement = this.element;
|
|
215
|
+
newElement = document.createElement("div");
|
|
216
|
+
|
|
217
|
+
//transfer attributes to new element
|
|
218
|
+
var attributes = element.attributes;
|
|
219
|
+
|
|
220
|
+
// loop through attributes and apply them on div
|
|
221
|
+
for(var i in attributes){
|
|
222
|
+
if(typeof attributes[i] == "object"){
|
|
223
|
+
newElement.setAttribute(attributes[i].name, attributes[i].value);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// replace table with div element
|
|
228
|
+
element.parentNode.replaceChild(newElement, element);
|
|
229
|
+
|
|
230
|
+
this.element = element = newElement;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
element.classList.add("tabulator");
|
|
234
|
+
element.setAttribute("role", "grid");
|
|
235
|
+
element.setAttribute("aria-owns", "tabulator-table-body");
|
|
236
|
+
|
|
237
|
+
//empty element
|
|
238
|
+
while(element.firstChild) element.removeChild(element.firstChild);
|
|
239
|
+
|
|
240
|
+
//set table height
|
|
241
|
+
if(options.height){
|
|
242
|
+
options.height = isNaN(options.height) ? options.height : options.height + "px";
|
|
243
|
+
element.style.height = options.height;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
//set table min height
|
|
247
|
+
if(options.minHeight !== false){
|
|
248
|
+
options.minHeight = isNaN(options.minHeight) ? options.minHeight : options.minHeight + "px";
|
|
249
|
+
element.style.minHeight = options.minHeight;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
//set table maxHeight
|
|
253
|
+
if(options.maxHeight !== false){
|
|
254
|
+
options.maxHeight = isNaN(options.maxHeight) ? options.maxHeight : options.maxHeight + "px";
|
|
255
|
+
element.style.maxHeight = options.maxHeight;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
//initialize core systems and modules
|
|
260
|
+
_initializeTable(){
|
|
261
|
+
var element = this.element,
|
|
262
|
+
options = this.options;
|
|
263
|
+
|
|
264
|
+
this.interactionMonitor.initialize();
|
|
265
|
+
|
|
266
|
+
this.columnManager.initialize();
|
|
267
|
+
this.rowManager.initialize();
|
|
268
|
+
|
|
269
|
+
this._detectBrowser();
|
|
270
|
+
|
|
271
|
+
//initialize core modules
|
|
272
|
+
this.modulesCore.forEach((mod) => {
|
|
273
|
+
mod.initialize();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
//build table elements
|
|
277
|
+
element.appendChild(this.columnManager.getElement());
|
|
278
|
+
element.appendChild(this.rowManager.getElement());
|
|
279
|
+
|
|
280
|
+
if(options.footerElement){
|
|
281
|
+
this.footerManager.activate();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if(options.autoColumns && options.data){
|
|
285
|
+
|
|
286
|
+
this.columnManager.generateColumnsFromRowData(this.options.data);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
//initialize regular modules
|
|
290
|
+
this.modulesRegular.forEach((mod) => {
|
|
291
|
+
mod.initialize();
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
this.columnManager.setColumns(options.columns);
|
|
295
|
+
|
|
296
|
+
this.eventBus.dispatch("table-built");
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
_loadInitialData(){
|
|
300
|
+
return this.dataLoader.load(this.options.data)
|
|
301
|
+
.finally(() => {
|
|
302
|
+
this.columnManager.verticalAlignHeaders();
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
//deconstructor
|
|
307
|
+
destroy(){
|
|
308
|
+
var element = this.element;
|
|
309
|
+
|
|
310
|
+
this.destroyed = true;
|
|
311
|
+
|
|
312
|
+
this.constructor.registry.deregister(this); //deregister table from inter-device communication
|
|
313
|
+
|
|
314
|
+
this.eventBus.dispatch("table-destroy");
|
|
315
|
+
|
|
316
|
+
//clear row data
|
|
317
|
+
this.rowManager.destroy();
|
|
318
|
+
|
|
319
|
+
//clear DOM
|
|
320
|
+
while(element.firstChild) element.removeChild(element.firstChild);
|
|
321
|
+
element.classList.remove("tabulator");
|
|
322
|
+
element.removeAttribute("tabulator-layout");
|
|
323
|
+
|
|
324
|
+
this.externalEvents.dispatch("tableDestroyed");
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
_detectBrowser(){
|
|
328
|
+
var ua = navigator.userAgent||navigator.vendor||window.opera;
|
|
329
|
+
|
|
330
|
+
if(ua.indexOf("Trident") > -1){
|
|
331
|
+
this.browser = "ie";
|
|
332
|
+
this.browserSlow = true;
|
|
333
|
+
}else if(ua.indexOf("Edge") > -1){
|
|
334
|
+
this.browser = "edge";
|
|
335
|
+
this.browserSlow = true;
|
|
336
|
+
}else if(ua.indexOf("Firefox") > -1){
|
|
337
|
+
this.browser = "firefox";
|
|
338
|
+
this.browserSlow = false;
|
|
339
|
+
}else if(ua.indexOf("Mac OS") > -1){
|
|
340
|
+
this.browser = "safari";
|
|
341
|
+
this.browserSlow = false;
|
|
342
|
+
}else{
|
|
343
|
+
this.browser = "other";
|
|
344
|
+
this.browserSlow = false;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
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));
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
initGuard(func, msg){
|
|
351
|
+
var stack, line;
|
|
352
|
+
|
|
353
|
+
if(this.options.debugInitialization && !this.initialized){
|
|
354
|
+
if(!func){
|
|
355
|
+
stack = new Error().stack.split("\n");
|
|
356
|
+
|
|
357
|
+
line = stack[0] == "Error" ? stack[2] : stack[1];
|
|
358
|
+
|
|
359
|
+
if(line[0] == " "){
|
|
360
|
+
func = line.trim().split(" ")[1].split(".")[1];
|
|
361
|
+
}else{
|
|
362
|
+
func = line.trim().split("@")[0];
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
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 : ""));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return this.initialized;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
////////////////// Data Handling //////////////////
|
|
373
|
+
//block table redrawing
|
|
374
|
+
blockRedraw(){
|
|
375
|
+
this.initGuard();
|
|
376
|
+
|
|
377
|
+
this.eventBus.dispatch("redraw-blocking");
|
|
378
|
+
|
|
379
|
+
this.rowManager.blockRedraw();
|
|
380
|
+
this.columnManager.blockRedraw();
|
|
381
|
+
|
|
382
|
+
this.eventBus.dispatch("redraw-blocked");
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
//restore table redrawing
|
|
386
|
+
restoreRedraw(){
|
|
387
|
+
this.initGuard();
|
|
388
|
+
|
|
389
|
+
this.eventBus.dispatch("redraw-restoring");
|
|
390
|
+
|
|
391
|
+
this.rowManager.restoreRedraw();
|
|
392
|
+
this.columnManager.restoreRedraw();
|
|
393
|
+
|
|
394
|
+
this.eventBus.dispatch("redraw-restored");
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
//load data
|
|
398
|
+
setData(data, params, config){
|
|
399
|
+
this.initGuard(false, "To set initial data please use the 'data' property in the table constructor.");
|
|
400
|
+
|
|
401
|
+
return this.dataLoader.load(data, params, config, false);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
//clear data
|
|
405
|
+
clearData(){
|
|
406
|
+
this.initGuard();
|
|
407
|
+
|
|
408
|
+
this.dataLoader.blockActiveLoad();
|
|
409
|
+
this.rowManager.clearData();
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
//get table data array
|
|
413
|
+
getData(active){
|
|
414
|
+
return this.rowManager.getData(active);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
//get table data array count
|
|
418
|
+
getDataCount(active){
|
|
419
|
+
return this.rowManager.getDataCount(active);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
//replace data, keeping table in position with same sort
|
|
423
|
+
replaceData(data, params, config){
|
|
424
|
+
this.initGuard();
|
|
425
|
+
|
|
426
|
+
return this.dataLoader.load(data, params, config, true, true);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
//update table data
|
|
430
|
+
updateData(data){
|
|
431
|
+
var responses = 0;
|
|
432
|
+
|
|
433
|
+
this.initGuard();
|
|
434
|
+
|
|
435
|
+
return new Promise((resolve, reject) => {
|
|
436
|
+
this.dataLoader.blockActiveLoad();
|
|
437
|
+
|
|
438
|
+
if(typeof data === "string"){
|
|
439
|
+
data = JSON.parse(data);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if(data && data.length > 0){
|
|
443
|
+
data.forEach((item) => {
|
|
444
|
+
var row = this.rowManager.findRow(item[this.options.index]);
|
|
445
|
+
|
|
446
|
+
if(row){
|
|
447
|
+
responses++;
|
|
448
|
+
|
|
449
|
+
row.updateData(item)
|
|
450
|
+
.then(()=>{
|
|
451
|
+
responses--;
|
|
452
|
+
|
|
453
|
+
if(!responses){
|
|
454
|
+
resolve();
|
|
455
|
+
}
|
|
456
|
+
})
|
|
457
|
+
.catch((e) => {
|
|
458
|
+
reject("Update Error - Unable to update row", item, e);
|
|
459
|
+
});
|
|
460
|
+
}else{
|
|
461
|
+
reject("Update Error - Unable to find row", item);
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
}else{
|
|
465
|
+
console.warn("Update Error - No data provided");
|
|
466
|
+
reject("Update Error - No data provided");
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
addData(data, pos, index){
|
|
472
|
+
this.initGuard();
|
|
473
|
+
|
|
474
|
+
return new Promise((resolve, reject) => {
|
|
475
|
+
this.dataLoader.blockActiveLoad();
|
|
476
|
+
|
|
477
|
+
if(typeof data === "string"){
|
|
478
|
+
data = JSON.parse(data);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if(data){
|
|
482
|
+
this.rowManager.addRows(data, pos, index)
|
|
483
|
+
.then((rows) => {
|
|
484
|
+
var output = [];
|
|
485
|
+
|
|
486
|
+
rows.forEach(function(row){
|
|
487
|
+
output.push(row.getComponent());
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
resolve(output);
|
|
491
|
+
});
|
|
492
|
+
}else{
|
|
493
|
+
console.warn("Update Error - No data provided");
|
|
494
|
+
reject("Update Error - No data provided");
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
//update table data
|
|
500
|
+
updateOrAddData(data){
|
|
501
|
+
var rows = [],
|
|
502
|
+
responses = 0;
|
|
503
|
+
|
|
504
|
+
this.initGuard();
|
|
505
|
+
|
|
506
|
+
return new Promise((resolve, reject) => {
|
|
507
|
+
this.dataLoader.blockActiveLoad();
|
|
508
|
+
|
|
509
|
+
if(typeof data === "string"){
|
|
510
|
+
data = JSON.parse(data);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if(data && data.length > 0){
|
|
514
|
+
data.forEach((item) => {
|
|
515
|
+
var row = this.rowManager.findRow(item[this.options.index]);
|
|
516
|
+
|
|
517
|
+
responses++;
|
|
518
|
+
|
|
519
|
+
if(row){
|
|
520
|
+
row.updateData(item)
|
|
521
|
+
.then(()=>{
|
|
522
|
+
responses--;
|
|
523
|
+
rows.push(row.getComponent());
|
|
524
|
+
|
|
525
|
+
if(!responses){
|
|
526
|
+
resolve(rows);
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}else{
|
|
530
|
+
this.rowManager.addRows(item)
|
|
531
|
+
.then((newRows)=>{
|
|
532
|
+
responses--;
|
|
533
|
+
rows.push(newRows[0].getComponent());
|
|
534
|
+
|
|
535
|
+
if(!responses){
|
|
536
|
+
resolve(rows);
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
}else{
|
|
542
|
+
console.warn("Update Error - No data provided");
|
|
543
|
+
reject("Update Error - No data provided");
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
//get row object
|
|
549
|
+
getRow(index){
|
|
550
|
+
var row = this.rowManager.findRow(index);
|
|
551
|
+
|
|
552
|
+
if(row){
|
|
553
|
+
return row.getComponent();
|
|
554
|
+
}else{
|
|
555
|
+
console.warn("Find Error - No matching row found:", index);
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
//get row object
|
|
561
|
+
getRowFromPosition(position){
|
|
562
|
+
var row = this.rowManager.getRowFromPosition(position);
|
|
563
|
+
|
|
564
|
+
if(row){
|
|
565
|
+
return row.getComponent();
|
|
566
|
+
}else{
|
|
567
|
+
console.warn("Find Error - No matching row found:", position);
|
|
568
|
+
return false;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
//delete row from table
|
|
573
|
+
deleteRow(index){
|
|
574
|
+
var foundRows = [];
|
|
575
|
+
|
|
576
|
+
this.initGuard();
|
|
577
|
+
|
|
578
|
+
if(!Array.isArray(index)){
|
|
579
|
+
index = [index];
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
//find matching rows
|
|
583
|
+
for(let item of index){
|
|
584
|
+
let row = this.rowManager.findRow(item, true);
|
|
585
|
+
|
|
586
|
+
if(row){
|
|
587
|
+
foundRows.push(row);
|
|
588
|
+
}else{
|
|
589
|
+
console.error("Delete Error - No matching row found:", item);
|
|
590
|
+
return Promise.reject("Delete Error - No matching row found");
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
//sort rows into correct order to ensure smooth delete from table
|
|
595
|
+
foundRows.sort((a, b) => {
|
|
596
|
+
return this.rowManager.rows.indexOf(a) > this.rowManager.rows.indexOf(b) ? 1 : -1;
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
//delete rows
|
|
600
|
+
foundRows.forEach((row) =>{
|
|
601
|
+
row.delete();
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
this.rowManager.reRenderInPosition();
|
|
605
|
+
|
|
606
|
+
return Promise.resolve();
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
//add row to table
|
|
610
|
+
addRow(data, pos, index){
|
|
611
|
+
this.initGuard();
|
|
612
|
+
|
|
613
|
+
if(typeof data === "string"){
|
|
614
|
+
data = JSON.parse(data);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
return this.rowManager.addRows(data, pos, index, true)
|
|
618
|
+
.then((rows)=>{
|
|
619
|
+
return rows[0].getComponent();
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
//update a row if it exists otherwise create it
|
|
624
|
+
updateOrAddRow(index, data){
|
|
625
|
+
var row = this.rowManager.findRow(index);
|
|
626
|
+
|
|
627
|
+
this.initGuard();
|
|
628
|
+
|
|
629
|
+
if(typeof data === "string"){
|
|
630
|
+
data = JSON.parse(data);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
if(row){
|
|
634
|
+
return row.updateData(data)
|
|
635
|
+
.then(()=>{
|
|
636
|
+
return row.getComponent();
|
|
637
|
+
});
|
|
638
|
+
}else{
|
|
639
|
+
return this.rowManager.addRows(data)
|
|
640
|
+
.then((rows)=>{
|
|
641
|
+
return rows[0].getComponent();
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
//update row data
|
|
647
|
+
updateRow(index, data){
|
|
648
|
+
var row = this.rowManager.findRow(index);
|
|
649
|
+
|
|
650
|
+
this.initGuard();
|
|
651
|
+
|
|
652
|
+
if(typeof data === "string"){
|
|
653
|
+
data = JSON.parse(data);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
if(row){
|
|
657
|
+
return row.updateData(data)
|
|
658
|
+
.then(()=>{
|
|
659
|
+
return Promise.resolve(row.getComponent());
|
|
660
|
+
});
|
|
661
|
+
}else{
|
|
662
|
+
console.warn("Update Error - No matching row found:", index);
|
|
663
|
+
return Promise.reject("Update Error - No matching row found");
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
//scroll to row in DOM
|
|
668
|
+
scrollToRow(index, position, ifVisible){
|
|
669
|
+
var row = this.rowManager.findRow(index);
|
|
670
|
+
|
|
671
|
+
if(row){
|
|
672
|
+
return this.rowManager.scrollToRow(row, position, ifVisible);
|
|
673
|
+
}else{
|
|
674
|
+
console.warn("Scroll Error - No matching row found:", index);
|
|
675
|
+
return Promise.reject("Scroll Error - No matching row found");
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
moveRow(from, to, after){
|
|
680
|
+
var fromRow = this.rowManager.findRow(from);
|
|
681
|
+
|
|
682
|
+
this.initGuard();
|
|
683
|
+
|
|
684
|
+
if(fromRow){
|
|
685
|
+
fromRow.moveToRow(to, after);
|
|
686
|
+
}else{
|
|
687
|
+
console.warn("Move Error - No matching row found:", from);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
getRows(active){
|
|
692
|
+
return this.rowManager.getComponents(active);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
//get position of row in table
|
|
696
|
+
getRowPosition(index){
|
|
697
|
+
var row = this.rowManager.findRow(index);
|
|
698
|
+
|
|
699
|
+
if(row){
|
|
700
|
+
return row.getPosition();
|
|
701
|
+
}else{
|
|
702
|
+
console.warn("Position Error - No matching row found:", index);
|
|
703
|
+
return false;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/////////////// Column Functions ///////////////
|
|
708
|
+
setColumns(definition){
|
|
709
|
+
this.initGuard(false, "To set initial columns please use the 'columns' property in the table constructor");
|
|
710
|
+
|
|
711
|
+
this.columnManager.setColumns(definition);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
getColumns(structured){
|
|
715
|
+
return this.columnManager.getComponents(structured);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
getColumn(field){
|
|
719
|
+
var column = this.columnManager.findColumn(field);
|
|
720
|
+
|
|
721
|
+
if(column){
|
|
722
|
+
return column.getComponent();
|
|
723
|
+
}else{
|
|
724
|
+
console.warn("Find Error - No matching column found:", field);
|
|
725
|
+
return false;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
getColumnDefinitions(){
|
|
730
|
+
return this.columnManager.getDefinitionTree();
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
showColumn(field){
|
|
734
|
+
var column = this.columnManager.findColumn(field);
|
|
735
|
+
|
|
736
|
+
this.initGuard();
|
|
737
|
+
|
|
738
|
+
if(column){
|
|
739
|
+
column.show();
|
|
740
|
+
}else{
|
|
741
|
+
console.warn("Column Show Error - No matching column found:", field);
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
hideColumn(field){
|
|
747
|
+
var column = this.columnManager.findColumn(field);
|
|
748
|
+
|
|
749
|
+
this.initGuard();
|
|
750
|
+
|
|
751
|
+
if(column){
|
|
752
|
+
column.hide();
|
|
753
|
+
}else{
|
|
754
|
+
console.warn("Column Hide Error - No matching column found:", field);
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
toggleColumn(field){
|
|
760
|
+
var column = this.columnManager.findColumn(field);
|
|
761
|
+
|
|
762
|
+
this.initGuard();
|
|
763
|
+
|
|
764
|
+
if(column){
|
|
765
|
+
if(column.visible){
|
|
766
|
+
column.hide();
|
|
767
|
+
}else{
|
|
768
|
+
column.show();
|
|
769
|
+
}
|
|
770
|
+
}else{
|
|
771
|
+
console.warn("Column Visibility Toggle Error - No matching column found:", field);
|
|
772
|
+
return false;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
addColumn(definition, before, field){
|
|
777
|
+
var column = this.columnManager.findColumn(field);
|
|
778
|
+
|
|
779
|
+
this.initGuard();
|
|
780
|
+
|
|
781
|
+
return this.columnManager.addColumn(definition, before, column)
|
|
782
|
+
.then((column) => {
|
|
783
|
+
return column.getComponent();
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
deleteColumn(field){
|
|
788
|
+
var column = this.columnManager.findColumn(field);
|
|
789
|
+
|
|
790
|
+
this.initGuard();
|
|
791
|
+
|
|
792
|
+
if(column){
|
|
793
|
+
return column.delete();
|
|
794
|
+
}else{
|
|
795
|
+
console.warn("Column Delete Error - No matching column found:", field);
|
|
796
|
+
return Promise.reject();
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
updateColumnDefinition(field, definition){
|
|
801
|
+
var column = this.columnManager.findColumn(field);
|
|
802
|
+
|
|
803
|
+
this.initGuard();
|
|
804
|
+
|
|
805
|
+
if(column){
|
|
806
|
+
return column.updateDefinition(definition);
|
|
807
|
+
}else{
|
|
808
|
+
console.warn("Column Update Error - No matching column found:", field);
|
|
809
|
+
return Promise.reject();
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
moveColumn(from, to, after){
|
|
814
|
+
var fromColumn = this.columnManager.findColumn(from),
|
|
815
|
+
toColumn = this.columnManager.findColumn(to);
|
|
816
|
+
|
|
817
|
+
this.initGuard();
|
|
818
|
+
|
|
819
|
+
if(fromColumn){
|
|
820
|
+
if(toColumn){
|
|
821
|
+
this.columnManager.moveColumn(fromColumn, toColumn, after);
|
|
822
|
+
}else{
|
|
823
|
+
console.warn("Move Error - No matching column found:", toColumn);
|
|
824
|
+
}
|
|
825
|
+
}else{
|
|
826
|
+
console.warn("Move Error - No matching column found:", from);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
//scroll to column in DOM
|
|
831
|
+
scrollToColumn(field, position, ifVisible){
|
|
832
|
+
return new Promise((resolve, reject) => {
|
|
833
|
+
var column = this.columnManager.findColumn(field);
|
|
834
|
+
|
|
835
|
+
if(column){
|
|
836
|
+
return this.columnManager.scrollToColumn(column, position, ifVisible);
|
|
837
|
+
}else{
|
|
838
|
+
console.warn("Scroll Error - No matching column found:", field);
|
|
839
|
+
return Promise.reject("Scroll Error - No matching column found");
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
//////////// General Public Functions ////////////
|
|
845
|
+
//redraw list without updating data
|
|
846
|
+
redraw(force){
|
|
847
|
+
this.initGuard();
|
|
848
|
+
|
|
849
|
+
this.columnManager.redraw(force);
|
|
850
|
+
this.rowManager.redraw(force);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
setHeight(height){
|
|
854
|
+
this.options.height = isNaN(height) ? height : height + "px";
|
|
855
|
+
this.element.style.height = this.options.height;
|
|
856
|
+
this.rowManager.initializeRenderer();
|
|
857
|
+
this.rowManager.redraw(true);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
setMaxHeight(maxHeight){
|
|
861
|
+
this.options.maxHeight = isNaN(maxHeight) ? maxHeight : maxHeight + "px";
|
|
862
|
+
this.element.style.maxHeight = this.options.maxHeight;
|
|
863
|
+
this.rowManager.initializeRenderer();
|
|
864
|
+
this.rowManager.redraw(true);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
setMinHeight(minHeight){
|
|
868
|
+
this.options.minHeight = isNaN(minHeight) ? minHeight : minHeight + "px";
|
|
869
|
+
this.element.style.minHeight = this.options.minHeight;
|
|
870
|
+
this.rowManager.initializeRenderer();
|
|
871
|
+
this.rowManager.redraw(true);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
//////////////////// Event Bus ///////////////////
|
|
875
|
+
|
|
876
|
+
on(key, callback){
|
|
877
|
+
this.externalEvents.subscribe(key, callback);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
off(key, callback){
|
|
881
|
+
this.externalEvents.unsubscribe(key, callback);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
dispatchEvent(){
|
|
885
|
+
var args = Array.from(arguments);
|
|
886
|
+
args.shift();
|
|
887
|
+
|
|
888
|
+
this.externalEvents.dispatch(...arguments);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
//////////////////// Alerts ///////////////////
|
|
892
|
+
|
|
893
|
+
alert(contents, type){
|
|
894
|
+
this.initGuard();
|
|
895
|
+
|
|
896
|
+
this.alertManager.alert(contents, type);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
clearAlert(){
|
|
900
|
+
this.initGuard();
|
|
901
|
+
|
|
902
|
+
this.alertManager.clear();
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
////////////// Extension Management //////////////
|
|
906
|
+
modExists(plugin, required){
|
|
907
|
+
if(this.modules[plugin]){
|
|
908
|
+
return true;
|
|
909
|
+
}else{
|
|
910
|
+
if(required){
|
|
911
|
+
console.error("Tabulator Module Not Installed: " + plugin);
|
|
912
|
+
}
|
|
913
|
+
return false;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
module(key){
|
|
918
|
+
var mod = this.modules[key];
|
|
919
|
+
|
|
920
|
+
if(!mod){
|
|
921
|
+
console.error("Tabulator module not installed: " + key);
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
return mod;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
export default Tabulator;
|