tabulator-tables 5.6.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bower.json +1 -1
- package/build/{Bundler.js → Bundler.mjs} +8 -6
- package/build/rollup.mjs +9 -0
- package/dist/css/tabulator.css +67 -5
- 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 +77 -5
- 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 +83 -5
- 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 +83 -5
- package/dist/css/tabulator_bootstrap5.css.map +1 -1
- package/dist/css/tabulator_bootstrap5.min.css +1 -1
- package/dist/css/tabulator_bootstrap5.min.css.map +1 -1
- package/dist/css/tabulator_bulma.css +89 -5
- 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 +82 -5
- 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 +77 -5
- 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 +87 -5
- 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 +79 -5
- 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 +80 -5
- 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 +90 -5
- 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 +3865 -2755
- 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 +3857 -2745
- 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 +17 -17
- package/src/js/builds/esm.js +2 -0
- package/src/js/core/ColumnManager.js +15 -0
- package/src/js/core/Module.js +2 -4
- package/src/js/core/RowManager.js +4 -6
- package/src/js/core/Tabulator.js +36 -23
- package/src/js/core/TabulatorFull.js +15 -5
- package/src/js/core/cell/Cell.js +4 -0
- package/src/js/core/column/Column.js +231 -216
- package/src/js/core/column/ColumnComponent.js +1 -3
- package/src/js/core/defaults/options.js +1 -0
- package/src/js/core/modules/optional.js +2 -1
- package/src/js/core/row/Row.js +23 -11
- package/src/js/core/tools/DataLoader.js +1 -1
- package/src/js/core/tools/ModuleBinder.js +123 -75
- package/src/js/core/tools/TableRegistry.js +58 -55
- package/src/js/modules/Accessor/Accessor.js +7 -8
- package/src/js/modules/Accessor/defaults/accessors.js +5 -1
- package/src/js/modules/Ajax/Ajax.js +10 -12
- package/src/js/modules/Clipboard/Clipboard.js +10 -10
- package/src/js/modules/Clipboard/defaults/pasteActions.js +0 -43
- package/src/js/modules/Clipboard/defaults/pasteParsers.js +0 -55
- 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 +2 -4
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +16 -18
- package/src/js/modules/Comms/Comms.js +5 -8
- package/src/js/modules/DataTree/DataTree.js +11 -11
- package/src/js/modules/Download/Download.js +9 -11
- package/src/js/modules/Edit/Edit.js +63 -21
- package/src/js/modules/Edit/List.js +12 -12
- package/src/js/modules/Edit/defaults/editors/datetime.js +1 -1
- package/src/js/modules/Edit/defaults/editors/time.js +1 -1
- package/src/js/modules/Edit/defaults/editors.js +0 -4
- package/src/js/modules/Export/Export.js +70 -62
- package/src/js/modules/Export/ExportColumn.js +2 -4
- package/src/js/modules/Export/ExportRow.js +2 -4
- 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 +7 -9
- package/src/js/modules/Format/Format.js +7 -9
- package/src/js/modules/Format/defaults/formatters.js +0 -4
- package/src/js/modules/FrozenColumns/FrozenColumns.js +9 -6
- package/src/js/modules/FrozenRows/FrozenRows.js +4 -6
- package/src/js/modules/GroupRows/Group.js +2 -4
- package/src/js/modules/GroupRows/GroupComponent.js +2 -4
- package/src/js/modules/GroupRows/GroupRows.js +4 -6
- package/src/js/modules/History/History.js +10 -10
- 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 +4 -6
- package/src/js/modules/Import/Import.js +7 -9
- package/src/js/modules/Import/defaults/importers/array.js +2 -4
- package/src/js/modules/Import/defaults/importers/csv.js +2 -4
- package/src/js/modules/Interaction/Interaction.js +4 -6
- package/src/js/modules/Keybindings/Keybindings.js +8 -10
- package/src/js/modules/Keybindings/defaults/actions.js +5 -71
- package/src/js/modules/Keybindings/defaults/bindings.js +0 -16
- package/src/js/modules/Layout/Layout.js +7 -9
- package/src/js/modules/Localize/Localize.js +7 -9
- package/src/js/modules/Menu/Menu.js +7 -9
- package/src/js/modules/MoveColumns/MoveColumns.js +6 -8
- package/src/js/modules/MoveRows/MoveRows.js +13 -45
- 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 +7 -9
- package/src/js/modules/Page/Page.js +7 -9
- package/src/js/modules/Persistence/Persistence.js +10 -12
- package/src/js/modules/Popup/Popup.js +4 -8
- package/src/js/modules/Print/Print.js +4 -6
- package/src/js/modules/ReactiveData/ReactiveData.js +4 -9
- package/src/js/modules/ResizeColumns/ResizeColumns.js +91 -53
- package/src/js/modules/ResizeRows/ResizeRows.js +41 -8
- package/src/js/modules/ResizeTable/ResizeTable.js +4 -6
- package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +15 -9
- package/src/js/modules/ResponsiveLayout/extensions/extensions.js +9 -0
- package/src/js/modules/SelectRange/Range.js +40 -21
- package/src/js/modules/SelectRange/RangeComponent.js +2 -4
- package/src/js/modules/SelectRange/SelectRange.js +88 -43
- 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 +12 -12
- package/src/js/modules/SelectRow/extensions/extensions.js +9 -0
- package/src/js/modules/Sort/Sort.js +16 -13
- 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 +6 -8
- package/src/js/modules/Validate/Validate.js +7 -9
- package/src/scss/tabulator.scss +86 -10
- package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +14 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +18 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +18 -0
- package/src/scss/themes/bulma/tabulator_bulma.scss +24 -0
- package/src/scss/themes/materialize/tabulator_materialize.scss +18 -0
- package/src/scss/themes/semanticui/tabulator_semanticui.scss +14 -0
- package/src/scss/themes/tabulator_midnight.scss +34 -21
- package/src/scss/themes/tabulator_modern.scss +23 -0
- package/src/scss/themes/tabulator_simple.scss +15 -0
- package/src/scss/themes/tabulator_site.scss +25 -0
- package/build/rollup.js +0 -6
- package/src/js/modules/Edit/defaults/editors/autocomplete.js +0 -12
- package/src/js/modules/Edit/defaults/editors/select.js +0 -10
- /package/src/js/modules/{Format/defaults → ResponsiveLayout/extensions}/formatters/responsiveCollapse.js +0 -0
- /package/src/js/modules/{Format/defaults → SelectRow/extensions}/formatters/rowSelection.js +0 -0
|
@@ -4,40 +4,43 @@ import defaultOptions from './defaults/options.js';
|
|
|
4
4
|
|
|
5
5
|
import Cell from '../cell/Cell.js';
|
|
6
6
|
|
|
7
|
-
class Column extends CoreFeature{
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export default class Column extends CoreFeature{
|
|
8
|
+
|
|
9
|
+
static defaultOptionList = defaultOptions;
|
|
10
|
+
|
|
11
|
+
constructor(def, parent, rowHeader){
|
|
10
12
|
super(parent.table);
|
|
11
|
-
|
|
13
|
+
|
|
12
14
|
this.definition = def; //column definition
|
|
13
15
|
this.parent = parent; //hold parent object
|
|
14
16
|
this.type = "column"; //type of element
|
|
15
17
|
this.columns = []; //child columns
|
|
16
18
|
this.cells = []; //cells bound to this column
|
|
19
|
+
this.isGroup = false;
|
|
20
|
+
this.isRowHeader = rowHeader;
|
|
17
21
|
this.element = this.createElement(); //column header element
|
|
18
22
|
this.contentElement = false;
|
|
19
23
|
this.titleHolderElement = false;
|
|
20
24
|
this.titleElement = false;
|
|
21
25
|
this.groupElement = this.createGroupElement(); //column group holder element
|
|
22
|
-
this.isGroup = false;
|
|
23
26
|
this.hozAlign = ""; //horizontal text alignment
|
|
24
27
|
this.vertAlign = ""; //vert text alignment
|
|
25
|
-
|
|
28
|
+
|
|
26
29
|
//multi dimensional filed handling
|
|
27
30
|
this.field ="";
|
|
28
31
|
this.fieldStructure = "";
|
|
29
32
|
this.getFieldValue = "";
|
|
30
33
|
this.setFieldValue = "";
|
|
31
|
-
|
|
34
|
+
|
|
32
35
|
this.titleDownload = null;
|
|
33
36
|
this.titleFormatterRendered = false;
|
|
34
|
-
|
|
37
|
+
|
|
35
38
|
this.mapDefinitions();
|
|
36
|
-
|
|
39
|
+
|
|
37
40
|
this.setField(this.definition.field);
|
|
38
|
-
|
|
41
|
+
|
|
39
42
|
this.modules = {}; //hold module variables;
|
|
40
|
-
|
|
43
|
+
|
|
41
44
|
this.width = null; //column width
|
|
42
45
|
this.widthStyled = ""; //column width pre-styled to improve render efficiency
|
|
43
46
|
this.maxWidth = null; //column maximum width
|
|
@@ -46,36 +49,40 @@ class Column extends CoreFeature{
|
|
|
46
49
|
this.minWidth = null; //column minimum width
|
|
47
50
|
this.minWidthStyled = ""; //column minimum pre-styled to improve render efficiency
|
|
48
51
|
this.widthFixed = false; //user has specified a width for this column
|
|
49
|
-
|
|
52
|
+
|
|
50
53
|
this.visible = true; //default visible state
|
|
51
|
-
|
|
54
|
+
|
|
52
55
|
this.component = null;
|
|
53
|
-
|
|
56
|
+
|
|
54
57
|
//initialize column
|
|
55
58
|
if(this.definition.columns){
|
|
56
|
-
|
|
59
|
+
|
|
57
60
|
this.isGroup = true;
|
|
58
|
-
|
|
61
|
+
|
|
59
62
|
this.definition.columns.forEach((def, i) => {
|
|
60
63
|
var newCol = new Column(def, this);
|
|
61
64
|
this.attachColumn(newCol);
|
|
62
65
|
});
|
|
63
|
-
|
|
66
|
+
|
|
64
67
|
this.checkColumnVisibility();
|
|
65
68
|
}else{
|
|
66
69
|
parent.registerColumnField(this);
|
|
67
70
|
}
|
|
68
|
-
|
|
71
|
+
|
|
69
72
|
this._initialize();
|
|
70
73
|
}
|
|
71
|
-
|
|
74
|
+
|
|
72
75
|
createElement (){
|
|
73
76
|
var el = document.createElement("div");
|
|
74
|
-
|
|
77
|
+
|
|
75
78
|
el.classList.add("tabulator-col");
|
|
76
79
|
el.setAttribute("role", "columnheader");
|
|
77
80
|
el.setAttribute("aria-sort", "none");
|
|
78
81
|
|
|
82
|
+
if(this.isRowHeader){
|
|
83
|
+
el.classList.add("tabulator-row-header");
|
|
84
|
+
}
|
|
85
|
+
|
|
79
86
|
switch(this.table.options.columnHeaderVertAlign){
|
|
80
87
|
case "middle":
|
|
81
88
|
el.style.justifyContent = "center";
|
|
@@ -84,21 +91,21 @@ class Column extends CoreFeature{
|
|
|
84
91
|
el.style.justifyContent = "flex-end";
|
|
85
92
|
break;
|
|
86
93
|
}
|
|
87
|
-
|
|
94
|
+
|
|
88
95
|
return el;
|
|
89
96
|
}
|
|
90
|
-
|
|
97
|
+
|
|
91
98
|
createGroupElement (){
|
|
92
99
|
var el = document.createElement("div");
|
|
93
|
-
|
|
100
|
+
|
|
94
101
|
el.classList.add("tabulator-col-group-cols");
|
|
95
|
-
|
|
102
|
+
|
|
96
103
|
return el;
|
|
97
104
|
}
|
|
98
|
-
|
|
105
|
+
|
|
99
106
|
mapDefinitions(){
|
|
100
107
|
var defaults = this.table.options.columnDefaults;
|
|
101
|
-
|
|
108
|
+
|
|
102
109
|
//map columnDefaults onto column definitions
|
|
103
110
|
if(defaults){
|
|
104
111
|
for(let key in defaults){
|
|
@@ -107,10 +114,10 @@ class Column extends CoreFeature{
|
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
116
|
}
|
|
110
|
-
|
|
117
|
+
|
|
111
118
|
this.definition = this.table.columnManager.optionsList.generate(Column.defaultOptionList, this.definition);
|
|
112
119
|
}
|
|
113
|
-
|
|
120
|
+
|
|
114
121
|
checkDefinition(){
|
|
115
122
|
Object.keys(this.definition).forEach((key) => {
|
|
116
123
|
if(Column.defaultOptionList.indexOf(key) === -1){
|
|
@@ -125,17 +132,17 @@ class Column extends CoreFeature{
|
|
|
125
132
|
this.getFieldValue = this.fieldStructure.length > 1 ? this._getNestedData : this._getFlatData;
|
|
126
133
|
this.setFieldValue = this.fieldStructure.length > 1 ? this._setNestedData : this._setFlatData;
|
|
127
134
|
}
|
|
128
|
-
|
|
135
|
+
|
|
129
136
|
//register column position with column manager
|
|
130
137
|
registerColumnPosition(column){
|
|
131
138
|
this.parent.registerColumnPosition(column);
|
|
132
139
|
}
|
|
133
|
-
|
|
140
|
+
|
|
134
141
|
//register column position with column manager
|
|
135
142
|
registerColumnField(column){
|
|
136
143
|
this.parent.registerColumnField(column);
|
|
137
144
|
}
|
|
138
|
-
|
|
145
|
+
|
|
139
146
|
//trigger position registration
|
|
140
147
|
reRegisterPosition(){
|
|
141
148
|
if(this.isGroup){
|
|
@@ -146,40 +153,40 @@ class Column extends CoreFeature{
|
|
|
146
153
|
this.registerColumnPosition(this);
|
|
147
154
|
}
|
|
148
155
|
}
|
|
149
|
-
|
|
156
|
+
|
|
150
157
|
//build header element
|
|
151
158
|
_initialize(){
|
|
152
159
|
var def = this.definition;
|
|
153
|
-
|
|
160
|
+
|
|
154
161
|
while(this.element.firstChild) this.element.removeChild(this.element.firstChild);
|
|
155
|
-
|
|
162
|
+
|
|
156
163
|
if(def.headerVertical){
|
|
157
164
|
this.element.classList.add("tabulator-col-vertical");
|
|
158
|
-
|
|
165
|
+
|
|
159
166
|
if(def.headerVertical === "flip"){
|
|
160
167
|
this.element.classList.add("tabulator-col-vertical-flip");
|
|
161
168
|
}
|
|
162
169
|
}
|
|
163
|
-
|
|
170
|
+
|
|
164
171
|
this.contentElement = this._buildColumnHeaderContent();
|
|
165
|
-
|
|
172
|
+
|
|
166
173
|
this.element.appendChild(this.contentElement);
|
|
167
|
-
|
|
174
|
+
|
|
168
175
|
if(this.isGroup){
|
|
169
176
|
this._buildGroupHeader();
|
|
170
177
|
}else{
|
|
171
178
|
this._buildColumnHeader();
|
|
172
179
|
}
|
|
173
|
-
|
|
180
|
+
|
|
174
181
|
this.dispatch("column-init", this);
|
|
175
182
|
}
|
|
176
|
-
|
|
183
|
+
|
|
177
184
|
//build header element for header
|
|
178
185
|
_buildColumnHeader(){
|
|
179
186
|
var def = this.definition;
|
|
180
|
-
|
|
187
|
+
|
|
181
188
|
this.dispatch("column-layout", this);
|
|
182
|
-
|
|
189
|
+
|
|
183
190
|
//set column visibility
|
|
184
191
|
if(typeof def.visible != "undefined"){
|
|
185
192
|
if(def.visible){
|
|
@@ -188,7 +195,7 @@ class Column extends CoreFeature{
|
|
|
188
195
|
this.hide(true);
|
|
189
196
|
}
|
|
190
197
|
}
|
|
191
|
-
|
|
198
|
+
|
|
192
199
|
//assign additional css classes to column header
|
|
193
200
|
if(def.cssClass){
|
|
194
201
|
var classNames = def.cssClass.split(" ");
|
|
@@ -196,14 +203,14 @@ class Column extends CoreFeature{
|
|
|
196
203
|
this.element.classList.add(className);
|
|
197
204
|
});
|
|
198
205
|
}
|
|
199
|
-
|
|
206
|
+
|
|
200
207
|
if(def.field){
|
|
201
208
|
this.element.setAttribute("tabulator-field", def.field);
|
|
202
209
|
}
|
|
203
|
-
|
|
210
|
+
|
|
204
211
|
//set min width if present
|
|
205
212
|
this.setMinWidth(parseInt(def.minWidth));
|
|
206
|
-
|
|
213
|
+
|
|
207
214
|
if (def.maxInitialWidth) {
|
|
208
215
|
this.maxInitialWidth = parseInt(def.maxInitialWidth);
|
|
209
216
|
}
|
|
@@ -211,59 +218,63 @@ class Column extends CoreFeature{
|
|
|
211
218
|
if(def.maxWidth){
|
|
212
219
|
this.setMaxWidth(parseInt(def.maxWidth));
|
|
213
220
|
}
|
|
214
|
-
|
|
221
|
+
|
|
215
222
|
this.reinitializeWidth();
|
|
216
|
-
|
|
223
|
+
|
|
217
224
|
//set horizontal text alignment
|
|
218
225
|
this.hozAlign = this.definition.hozAlign;
|
|
219
226
|
this.vertAlign = this.definition.vertAlign;
|
|
220
|
-
|
|
227
|
+
|
|
221
228
|
this.titleElement.style.textAlign = this.definition.headerHozAlign;
|
|
222
229
|
}
|
|
223
|
-
|
|
230
|
+
|
|
224
231
|
_buildColumnHeaderContent(){
|
|
225
232
|
var contentElement = document.createElement("div");
|
|
226
233
|
contentElement.classList.add("tabulator-col-content");
|
|
227
|
-
|
|
234
|
+
|
|
228
235
|
this.titleHolderElement = document.createElement("div");
|
|
229
236
|
this.titleHolderElement.classList.add("tabulator-col-title-holder");
|
|
230
|
-
|
|
237
|
+
|
|
231
238
|
contentElement.appendChild(this.titleHolderElement);
|
|
232
|
-
|
|
239
|
+
|
|
233
240
|
this.titleElement = this._buildColumnHeaderTitle();
|
|
234
|
-
|
|
241
|
+
|
|
235
242
|
this.titleHolderElement.appendChild(this.titleElement);
|
|
236
|
-
|
|
243
|
+
|
|
237
244
|
return contentElement;
|
|
238
245
|
}
|
|
239
|
-
|
|
246
|
+
|
|
240
247
|
//build title element of column
|
|
241
248
|
_buildColumnHeaderTitle(){
|
|
242
249
|
var def = this.definition;
|
|
243
|
-
|
|
250
|
+
|
|
244
251
|
var titleHolderElement = document.createElement("div");
|
|
245
252
|
titleHolderElement.classList.add("tabulator-col-title");
|
|
246
253
|
|
|
247
254
|
if(def.headerWordWrap){
|
|
248
255
|
titleHolderElement.classList.add("tabulator-col-title-wrap");
|
|
249
256
|
}
|
|
250
|
-
|
|
257
|
+
|
|
251
258
|
if(def.editableTitle){
|
|
252
259
|
var titleElement = document.createElement("input");
|
|
253
260
|
titleElement.classList.add("tabulator-title-editor");
|
|
254
|
-
|
|
261
|
+
|
|
255
262
|
titleElement.addEventListener("click", (e) => {
|
|
256
263
|
e.stopPropagation();
|
|
257
264
|
titleElement.focus();
|
|
258
265
|
});
|
|
259
|
-
|
|
266
|
+
|
|
267
|
+
titleElement.addEventListener("mousedown", (e) => {
|
|
268
|
+
e.stopPropagation();
|
|
269
|
+
});
|
|
270
|
+
|
|
260
271
|
titleElement.addEventListener("change", () => {
|
|
261
272
|
def.title = titleElement.value;
|
|
262
273
|
this.dispatchExternal("columnTitleChanged", this.getComponent());
|
|
263
274
|
});
|
|
264
|
-
|
|
275
|
+
|
|
265
276
|
titleHolderElement.appendChild(titleElement);
|
|
266
|
-
|
|
277
|
+
|
|
267
278
|
if(def.field){
|
|
268
279
|
this.langBind("columns|" + def.field, (text) => {
|
|
269
280
|
titleElement.value = text || (def.title || " ");
|
|
@@ -271,7 +282,7 @@ class Column extends CoreFeature{
|
|
|
271
282
|
}else{
|
|
272
283
|
titleElement.value = def.title || " ";
|
|
273
284
|
}
|
|
274
|
-
|
|
285
|
+
|
|
275
286
|
}else{
|
|
276
287
|
if(def.field){
|
|
277
288
|
this.langBind("columns|" + def.field, (text) => {
|
|
@@ -281,15 +292,15 @@ class Column extends CoreFeature{
|
|
|
281
292
|
this._formatColumnHeaderTitle(titleHolderElement, def.title || " ");
|
|
282
293
|
}
|
|
283
294
|
}
|
|
284
|
-
|
|
295
|
+
|
|
285
296
|
return titleHolderElement;
|
|
286
297
|
}
|
|
287
|
-
|
|
298
|
+
|
|
288
299
|
_formatColumnHeaderTitle(el, title){
|
|
289
300
|
var contents = this.chain("column-format", [this, title, el], null, () => {
|
|
290
301
|
return title;
|
|
291
302
|
});
|
|
292
|
-
|
|
303
|
+
|
|
293
304
|
switch(typeof contents){
|
|
294
305
|
case "object":
|
|
295
306
|
if(contents instanceof Node){
|
|
@@ -306,13 +317,13 @@ class Column extends CoreFeature{
|
|
|
306
317
|
el.innerHTML = contents;
|
|
307
318
|
}
|
|
308
319
|
}
|
|
309
|
-
|
|
320
|
+
|
|
310
321
|
//build header element for column group
|
|
311
322
|
_buildGroupHeader(){
|
|
312
323
|
this.element.classList.add("tabulator-col-group");
|
|
313
324
|
this.element.setAttribute("role", "columngroup");
|
|
314
325
|
this.element.setAttribute("aria-title", this.definition.title);
|
|
315
|
-
|
|
326
|
+
|
|
316
327
|
//asign additional css classes to column header
|
|
317
328
|
if(this.definition.cssClass){
|
|
318
329
|
var classNames = this.definition.cssClass.split(" ");
|
|
@@ -320,53 +331,53 @@ class Column extends CoreFeature{
|
|
|
320
331
|
this.element.classList.add(className);
|
|
321
332
|
});
|
|
322
333
|
}
|
|
323
|
-
|
|
334
|
+
|
|
324
335
|
this.titleElement.style.textAlign = this.definition.headerHozAlign;
|
|
325
|
-
|
|
336
|
+
|
|
326
337
|
this.element.appendChild(this.groupElement);
|
|
327
338
|
}
|
|
328
|
-
|
|
339
|
+
|
|
329
340
|
//flat field lookup
|
|
330
341
|
_getFlatData(data){
|
|
331
342
|
return data[this.field];
|
|
332
343
|
}
|
|
333
|
-
|
|
344
|
+
|
|
334
345
|
//nested field lookup
|
|
335
346
|
_getNestedData(data){
|
|
336
347
|
var dataObj = data,
|
|
337
348
|
structure = this.fieldStructure,
|
|
338
349
|
length = structure.length,
|
|
339
350
|
output;
|
|
340
|
-
|
|
351
|
+
|
|
341
352
|
for(let i = 0; i < length; i++){
|
|
342
|
-
|
|
353
|
+
|
|
343
354
|
dataObj = dataObj[structure[i]];
|
|
344
|
-
|
|
355
|
+
|
|
345
356
|
output = dataObj;
|
|
346
|
-
|
|
357
|
+
|
|
347
358
|
if(!dataObj){
|
|
348
359
|
break;
|
|
349
360
|
}
|
|
350
361
|
}
|
|
351
|
-
|
|
362
|
+
|
|
352
363
|
return output;
|
|
353
364
|
}
|
|
354
|
-
|
|
365
|
+
|
|
355
366
|
//flat field set
|
|
356
367
|
_setFlatData(data, value){
|
|
357
368
|
if(this.field){
|
|
358
369
|
data[this.field] = value;
|
|
359
370
|
}
|
|
360
371
|
}
|
|
361
|
-
|
|
372
|
+
|
|
362
373
|
//nested field set
|
|
363
374
|
_setNestedData(data, value){
|
|
364
375
|
var dataObj = data,
|
|
365
376
|
structure = this.fieldStructure,
|
|
366
377
|
length = structure.length;
|
|
367
|
-
|
|
378
|
+
|
|
368
379
|
for(let i = 0; i < length; i++){
|
|
369
|
-
|
|
380
|
+
|
|
370
381
|
if(i == length -1){
|
|
371
382
|
dataObj[structure[i]] = value;
|
|
372
383
|
}else{
|
|
@@ -377,39 +388,39 @@ class Column extends CoreFeature{
|
|
|
377
388
|
break;
|
|
378
389
|
}
|
|
379
390
|
}
|
|
380
|
-
|
|
391
|
+
|
|
381
392
|
dataObj = dataObj[structure[i]];
|
|
382
393
|
}
|
|
383
394
|
}
|
|
384
395
|
}
|
|
385
|
-
|
|
396
|
+
|
|
386
397
|
//attach column to this group
|
|
387
398
|
attachColumn(column){
|
|
388
399
|
if(this.groupElement){
|
|
389
400
|
this.columns.push(column);
|
|
390
401
|
this.groupElement.appendChild(column.getElement());
|
|
391
|
-
|
|
402
|
+
|
|
392
403
|
column.columnRendered();
|
|
393
404
|
}else{
|
|
394
405
|
console.warn("Column Warning - Column being attached to another column instead of column group");
|
|
395
406
|
}
|
|
396
407
|
}
|
|
397
|
-
|
|
408
|
+
|
|
398
409
|
//vertically align header in column
|
|
399
410
|
verticalAlign(alignment, height){
|
|
400
|
-
|
|
411
|
+
|
|
401
412
|
//calculate height of column header and group holder element
|
|
402
413
|
var parentHeight = this.parent.isGroup ? this.parent.getGroupElement().clientHeight : (height || this.parent.getHeadersElement().clientHeight);
|
|
403
414
|
// var parentHeight = this.parent.isGroup ? this.parent.getGroupElement().clientHeight : this.parent.getHeadersElement().clientHeight;
|
|
404
|
-
|
|
415
|
+
|
|
405
416
|
this.element.style.height = parentHeight + "px";
|
|
406
|
-
|
|
417
|
+
|
|
407
418
|
this.dispatch("column-height", this, this.element.style.height);
|
|
408
|
-
|
|
419
|
+
|
|
409
420
|
if(this.isGroup){
|
|
410
421
|
this.groupElement.style.minHeight = (parentHeight - this.contentElement.offsetHeight) + "px";
|
|
411
422
|
}
|
|
412
|
-
|
|
423
|
+
|
|
413
424
|
//vertically align cell contents
|
|
414
425
|
// if(!this.isGroup && alignment !== "top"){
|
|
415
426
|
// if(alignment === "bottom"){
|
|
@@ -418,46 +429,46 @@ class Column extends CoreFeature{
|
|
|
418
429
|
// this.element.style.paddingTop = ((this.element.clientHeight - this.contentElement.offsetHeight) / 2) + "px";
|
|
419
430
|
// }
|
|
420
431
|
// }
|
|
421
|
-
|
|
432
|
+
|
|
422
433
|
this.columns.forEach(function(column){
|
|
423
434
|
column.verticalAlign(alignment);
|
|
424
435
|
});
|
|
425
436
|
}
|
|
426
|
-
|
|
437
|
+
|
|
427
438
|
//clear vertical alignment
|
|
428
439
|
clearVerticalAlign(){
|
|
429
440
|
this.element.style.paddingTop = "";
|
|
430
441
|
this.element.style.height = "";
|
|
431
442
|
this.element.style.minHeight = "";
|
|
432
443
|
this.groupElement.style.minHeight = "";
|
|
433
|
-
|
|
444
|
+
|
|
434
445
|
this.columns.forEach(function(column){
|
|
435
446
|
column.clearVerticalAlign();
|
|
436
447
|
});
|
|
437
|
-
|
|
448
|
+
|
|
438
449
|
this.dispatch("column-height", this, "");
|
|
439
450
|
}
|
|
440
|
-
|
|
451
|
+
|
|
441
452
|
//// Retrieve Column Information ////
|
|
442
453
|
//return column header element
|
|
443
454
|
getElement(){
|
|
444
455
|
return this.element;
|
|
445
456
|
}
|
|
446
|
-
|
|
457
|
+
|
|
447
458
|
//return column group element
|
|
448
459
|
getGroupElement(){
|
|
449
460
|
return this.groupElement;
|
|
450
461
|
}
|
|
451
|
-
|
|
462
|
+
|
|
452
463
|
//return field name
|
|
453
464
|
getField(){
|
|
454
465
|
return this.field;
|
|
455
466
|
}
|
|
456
|
-
|
|
467
|
+
|
|
457
468
|
getTitleDownload() {
|
|
458
469
|
return this.titleDownload;
|
|
459
470
|
}
|
|
460
|
-
|
|
471
|
+
|
|
461
472
|
//return the first column in a group
|
|
462
473
|
getFirstColumn(){
|
|
463
474
|
if(!this.isGroup){
|
|
@@ -470,7 +481,7 @@ class Column extends CoreFeature{
|
|
|
470
481
|
}
|
|
471
482
|
}
|
|
472
483
|
}
|
|
473
|
-
|
|
484
|
+
|
|
474
485
|
//return the last column in a group
|
|
475
486
|
getLastColumn(){
|
|
476
487
|
if(!this.isGroup){
|
|
@@ -483,15 +494,15 @@ class Column extends CoreFeature{
|
|
|
483
494
|
}
|
|
484
495
|
}
|
|
485
496
|
}
|
|
486
|
-
|
|
497
|
+
|
|
487
498
|
//return all columns in a group
|
|
488
499
|
getColumns(traverse){
|
|
489
500
|
var columns = [];
|
|
490
|
-
|
|
501
|
+
|
|
491
502
|
if(traverse){
|
|
492
503
|
this.columns.forEach((column) => {
|
|
493
504
|
columns.push(column);
|
|
494
|
-
|
|
505
|
+
|
|
495
506
|
columns = columns.concat(column.getColumns(true));
|
|
496
507
|
});
|
|
497
508
|
}else{
|
|
@@ -500,12 +511,12 @@ class Column extends CoreFeature{
|
|
|
500
511
|
|
|
501
512
|
return columns;
|
|
502
513
|
}
|
|
503
|
-
|
|
514
|
+
|
|
504
515
|
//return all columns in a group
|
|
505
516
|
getCells(){
|
|
506
517
|
return this.cells;
|
|
507
518
|
}
|
|
508
|
-
|
|
519
|
+
|
|
509
520
|
//retrieve the top column in a group of columns
|
|
510
521
|
getTopColumn(){
|
|
511
522
|
if(this.parent.isGroup){
|
|
@@ -514,32 +525,32 @@ class Column extends CoreFeature{
|
|
|
514
525
|
return this;
|
|
515
526
|
}
|
|
516
527
|
}
|
|
517
|
-
|
|
528
|
+
|
|
518
529
|
//return column definition object
|
|
519
530
|
getDefinition(updateBranches){
|
|
520
531
|
var colDefs = [];
|
|
521
|
-
|
|
532
|
+
|
|
522
533
|
if(this.isGroup && updateBranches){
|
|
523
534
|
this.columns.forEach(function(column){
|
|
524
535
|
colDefs.push(column.getDefinition(true));
|
|
525
536
|
});
|
|
526
|
-
|
|
537
|
+
|
|
527
538
|
this.definition.columns = colDefs;
|
|
528
539
|
}
|
|
529
|
-
|
|
540
|
+
|
|
530
541
|
return this.definition;
|
|
531
542
|
}
|
|
532
|
-
|
|
543
|
+
|
|
533
544
|
//////////////////// Actions ////////////////////
|
|
534
545
|
checkColumnVisibility(){
|
|
535
546
|
var visible = false;
|
|
536
|
-
|
|
547
|
+
|
|
537
548
|
this.columns.forEach(function(column){
|
|
538
549
|
if(column.visible){
|
|
539
550
|
visible = true;
|
|
540
551
|
}
|
|
541
552
|
});
|
|
542
|
-
|
|
553
|
+
|
|
543
554
|
if(visible){
|
|
544
555
|
this.show();
|
|
545
556
|
this.dispatchExternal("columnVisibilityChanged", this.getComponent(), false);
|
|
@@ -547,144 +558,148 @@ class Column extends CoreFeature{
|
|
|
547
558
|
this.hide();
|
|
548
559
|
}
|
|
549
560
|
}
|
|
550
|
-
|
|
561
|
+
|
|
551
562
|
//show column
|
|
552
563
|
show(silent, responsiveToggle){
|
|
553
564
|
if(!this.visible){
|
|
554
565
|
this.visible = true;
|
|
555
|
-
|
|
566
|
+
|
|
556
567
|
this.element.style.display = "";
|
|
557
|
-
|
|
568
|
+
|
|
558
569
|
if(this.parent.isGroup){
|
|
559
570
|
this.parent.checkColumnVisibility();
|
|
560
571
|
}
|
|
561
|
-
|
|
572
|
+
|
|
562
573
|
this.cells.forEach(function(cell){
|
|
563
574
|
cell.show();
|
|
564
575
|
});
|
|
565
|
-
|
|
576
|
+
|
|
566
577
|
if(!this.isGroup && this.width === null){
|
|
567
578
|
this.reinitializeWidth();
|
|
568
579
|
}
|
|
569
|
-
|
|
580
|
+
|
|
570
581
|
this.table.columnManager.verticalAlignHeaders();
|
|
571
|
-
|
|
582
|
+
|
|
572
583
|
this.dispatch("column-show", this, responsiveToggle);
|
|
573
|
-
|
|
584
|
+
|
|
574
585
|
if(!silent){
|
|
575
586
|
this.dispatchExternal("columnVisibilityChanged", this.getComponent(), true);
|
|
576
587
|
}
|
|
577
|
-
|
|
588
|
+
|
|
578
589
|
if(this.parent.isGroup){
|
|
579
590
|
this.parent.matchChildWidths();
|
|
580
591
|
}
|
|
581
|
-
|
|
592
|
+
|
|
582
593
|
if(!this.silent){
|
|
583
594
|
this.table.columnManager.rerenderColumns();
|
|
584
595
|
}
|
|
585
596
|
}
|
|
586
597
|
}
|
|
587
|
-
|
|
598
|
+
|
|
588
599
|
//hide column
|
|
589
600
|
hide(silent, responsiveToggle){
|
|
590
601
|
if(this.visible){
|
|
591
602
|
this.visible = false;
|
|
592
|
-
|
|
603
|
+
|
|
593
604
|
this.element.style.display = "none";
|
|
594
|
-
|
|
605
|
+
|
|
595
606
|
this.table.columnManager.verticalAlignHeaders();
|
|
596
|
-
|
|
607
|
+
|
|
597
608
|
if(this.parent.isGroup){
|
|
598
609
|
this.parent.checkColumnVisibility();
|
|
599
610
|
}
|
|
600
|
-
|
|
611
|
+
|
|
601
612
|
this.cells.forEach(function(cell){
|
|
602
613
|
cell.hide();
|
|
603
614
|
});
|
|
604
|
-
|
|
615
|
+
|
|
605
616
|
this.dispatch("column-hide", this, responsiveToggle);
|
|
606
|
-
|
|
617
|
+
|
|
607
618
|
if(!silent){
|
|
608
619
|
this.dispatchExternal("columnVisibilityChanged", this.getComponent(), false);
|
|
609
620
|
}
|
|
610
|
-
|
|
621
|
+
|
|
611
622
|
if(this.parent.isGroup){
|
|
612
623
|
this.parent.matchChildWidths();
|
|
613
624
|
}
|
|
614
|
-
|
|
625
|
+
|
|
615
626
|
if(!this.silent){
|
|
616
627
|
this.table.columnManager.rerenderColumns();
|
|
617
628
|
}
|
|
618
629
|
}
|
|
619
630
|
}
|
|
620
|
-
|
|
631
|
+
|
|
621
632
|
matchChildWidths(){
|
|
622
633
|
var childWidth = 0;
|
|
623
|
-
|
|
634
|
+
|
|
624
635
|
if(this.contentElement && this.columns.length){
|
|
625
636
|
this.columns.forEach(function(column){
|
|
626
637
|
if(column.visible){
|
|
627
638
|
childWidth += column.getWidth();
|
|
628
639
|
}
|
|
629
640
|
});
|
|
630
|
-
|
|
641
|
+
|
|
631
642
|
this.contentElement.style.maxWidth = (childWidth - 1) + "px";
|
|
632
|
-
|
|
643
|
+
|
|
633
644
|
if(this.parent.isGroup){
|
|
634
645
|
this.parent.matchChildWidths();
|
|
635
646
|
}
|
|
636
647
|
}
|
|
637
648
|
}
|
|
638
|
-
|
|
649
|
+
|
|
639
650
|
removeChild(child){
|
|
640
651
|
var index = this.columns.indexOf(child);
|
|
641
|
-
|
|
652
|
+
|
|
642
653
|
if(index > -1){
|
|
643
654
|
this.columns.splice(index, 1);
|
|
644
655
|
}
|
|
645
|
-
|
|
656
|
+
|
|
646
657
|
if(!this.columns.length){
|
|
647
658
|
this.delete();
|
|
648
659
|
}
|
|
649
660
|
}
|
|
650
|
-
|
|
661
|
+
|
|
651
662
|
setWidth(width){
|
|
652
663
|
this.widthFixed = true;
|
|
653
664
|
this.setWidthActual(width);
|
|
654
665
|
}
|
|
655
|
-
|
|
666
|
+
|
|
656
667
|
setWidthActual(width){
|
|
657
668
|
if(isNaN(width)){
|
|
658
669
|
width = Math.floor((this.table.element.clientWidth/100) * parseInt(width));
|
|
659
670
|
}
|
|
660
|
-
|
|
671
|
+
|
|
661
672
|
width = Math.max(this.minWidth, width);
|
|
662
|
-
|
|
673
|
+
|
|
663
674
|
if(this.maxWidth){
|
|
664
675
|
width = Math.min(this.maxWidth, width);
|
|
665
676
|
}
|
|
666
|
-
|
|
677
|
+
|
|
667
678
|
this.width = width;
|
|
668
679
|
this.widthStyled = width ? width + "px" : "";
|
|
669
|
-
|
|
680
|
+
|
|
670
681
|
this.element.style.width = this.widthStyled;
|
|
671
|
-
|
|
682
|
+
|
|
672
683
|
if(!this.isGroup){
|
|
673
684
|
this.cells.forEach(function(cell){
|
|
674
685
|
cell.setWidth();
|
|
675
686
|
});
|
|
676
687
|
}
|
|
677
|
-
|
|
688
|
+
|
|
678
689
|
if(this.parent.isGroup){
|
|
679
690
|
this.parent.matchChildWidths();
|
|
680
691
|
}
|
|
681
|
-
|
|
692
|
+
|
|
682
693
|
this.dispatch("column-width", this);
|
|
694
|
+
|
|
695
|
+
if(this.subscribedExternal("columnWidth")){
|
|
696
|
+
this.dispatchExternal("columnWidth", this.getComponent());
|
|
697
|
+
}
|
|
683
698
|
}
|
|
684
|
-
|
|
699
|
+
|
|
685
700
|
checkCellHeights(){
|
|
686
701
|
var rows = [];
|
|
687
|
-
|
|
702
|
+
|
|
688
703
|
this.cells.forEach(function(cell){
|
|
689
704
|
if(cell.row.heightInitialized){
|
|
690
705
|
if(cell.row.getElement().offsetParent !== null){
|
|
@@ -695,19 +710,19 @@ class Column extends CoreFeature{
|
|
|
695
710
|
}
|
|
696
711
|
}
|
|
697
712
|
});
|
|
698
|
-
|
|
713
|
+
|
|
699
714
|
rows.forEach(function(row){
|
|
700
715
|
row.calcHeight();
|
|
701
716
|
});
|
|
702
|
-
|
|
717
|
+
|
|
703
718
|
rows.forEach(function(row){
|
|
704
719
|
row.setCellHeight();
|
|
705
720
|
});
|
|
706
721
|
}
|
|
707
|
-
|
|
722
|
+
|
|
708
723
|
getWidth(){
|
|
709
724
|
var width = 0;
|
|
710
|
-
|
|
725
|
+
|
|
711
726
|
if(this.isGroup){
|
|
712
727
|
this.columns.forEach(function(column){
|
|
713
728
|
if(column.visible){
|
|
@@ -717,58 +732,58 @@ class Column extends CoreFeature{
|
|
|
717
732
|
}else{
|
|
718
733
|
width = this.width;
|
|
719
734
|
}
|
|
720
|
-
|
|
735
|
+
|
|
721
736
|
return width;
|
|
722
737
|
}
|
|
723
|
-
|
|
738
|
+
|
|
724
739
|
getLeftOffset(){
|
|
725
740
|
var offset = this.element.offsetLeft;
|
|
726
|
-
|
|
741
|
+
|
|
727
742
|
if(this.parent.isGroup){
|
|
728
743
|
offset += this.parent.getLeftOffset();
|
|
729
744
|
}
|
|
730
|
-
|
|
745
|
+
|
|
731
746
|
return offset;
|
|
732
747
|
}
|
|
733
|
-
|
|
748
|
+
|
|
734
749
|
getHeight(){
|
|
735
750
|
return Math.ceil(this.element.getBoundingClientRect().height);
|
|
736
751
|
}
|
|
737
|
-
|
|
752
|
+
|
|
738
753
|
setMinWidth(minWidth){
|
|
739
754
|
if(this.maxWidth && minWidth > this.maxWidth){
|
|
740
755
|
minWidth = this.maxWidth;
|
|
741
|
-
|
|
756
|
+
|
|
742
757
|
console.warn("the minWidth ("+ minWidth + "px) for column '" + this.field + "' cannot be bigger that its maxWidth ("+ this.maxWidthStyled + ")");
|
|
743
758
|
}
|
|
744
|
-
|
|
759
|
+
|
|
745
760
|
this.minWidth = minWidth;
|
|
746
761
|
this.minWidthStyled = minWidth ? minWidth + "px" : "";
|
|
747
|
-
|
|
762
|
+
|
|
748
763
|
this.element.style.minWidth = this.minWidthStyled;
|
|
749
|
-
|
|
764
|
+
|
|
750
765
|
this.cells.forEach(function(cell){
|
|
751
766
|
cell.setMinWidth();
|
|
752
767
|
});
|
|
753
768
|
}
|
|
754
|
-
|
|
769
|
+
|
|
755
770
|
setMaxWidth(maxWidth){
|
|
756
771
|
if(this.minWidth && maxWidth < this.minWidth){
|
|
757
772
|
maxWidth = this.minWidth;
|
|
758
|
-
|
|
773
|
+
|
|
759
774
|
console.warn("the maxWidth ("+ maxWidth + "px) for column '" + this.field + "' cannot be smaller that its minWidth ("+ this.minWidthStyled + ")");
|
|
760
775
|
}
|
|
761
|
-
|
|
776
|
+
|
|
762
777
|
this.maxWidth = maxWidth;
|
|
763
778
|
this.maxWidthStyled = maxWidth ? maxWidth + "px" : "";
|
|
764
|
-
|
|
779
|
+
|
|
765
780
|
this.element.style.maxWidth = this.maxWidthStyled;
|
|
766
|
-
|
|
781
|
+
|
|
767
782
|
this.cells.forEach(function(cell){
|
|
768
783
|
cell.setMaxWidth();
|
|
769
784
|
});
|
|
770
785
|
}
|
|
771
|
-
|
|
786
|
+
|
|
772
787
|
delete(){
|
|
773
788
|
return new Promise((resolve, reject) => {
|
|
774
789
|
if(this.isGroup){
|
|
@@ -776,117 +791,117 @@ class Column extends CoreFeature{
|
|
|
776
791
|
column.delete();
|
|
777
792
|
});
|
|
778
793
|
}
|
|
779
|
-
|
|
794
|
+
|
|
780
795
|
this.dispatch("column-delete", this);
|
|
781
|
-
|
|
796
|
+
|
|
782
797
|
var cellCount = this.cells.length;
|
|
783
|
-
|
|
798
|
+
|
|
784
799
|
for(let i = 0; i < cellCount; i++){
|
|
785
800
|
this.cells[0].delete();
|
|
786
801
|
}
|
|
787
|
-
|
|
802
|
+
|
|
788
803
|
if(this.element.parentNode){
|
|
789
804
|
this.element.parentNode.removeChild(this.element);
|
|
790
805
|
}
|
|
791
|
-
|
|
806
|
+
|
|
792
807
|
this.element = false;
|
|
793
808
|
this.contentElement = false;
|
|
794
809
|
this.titleElement = false;
|
|
795
810
|
this.groupElement = false;
|
|
796
|
-
|
|
811
|
+
|
|
797
812
|
if(this.parent.isGroup){
|
|
798
813
|
this.parent.removeChild(this);
|
|
799
814
|
}
|
|
800
|
-
|
|
815
|
+
|
|
801
816
|
this.table.columnManager.deregisterColumn(this);
|
|
802
|
-
|
|
817
|
+
|
|
803
818
|
this.table.columnManager.rerenderColumns(true);
|
|
804
|
-
|
|
819
|
+
|
|
805
820
|
this.dispatch("column-deleted", this);
|
|
806
|
-
|
|
821
|
+
|
|
807
822
|
resolve();
|
|
808
823
|
});
|
|
809
824
|
}
|
|
810
|
-
|
|
825
|
+
|
|
811
826
|
columnRendered(){
|
|
812
827
|
if(this.titleFormatterRendered){
|
|
813
828
|
this.titleFormatterRendered();
|
|
814
829
|
}
|
|
815
|
-
|
|
830
|
+
|
|
816
831
|
this.dispatch("column-rendered", this);
|
|
817
832
|
}
|
|
818
|
-
|
|
833
|
+
|
|
819
834
|
//////////////// Cell Management /////////////////
|
|
820
835
|
//generate cell for this column
|
|
821
836
|
generateCell(row){
|
|
822
837
|
var cell = new Cell(this, row);
|
|
823
|
-
|
|
838
|
+
|
|
824
839
|
this.cells.push(cell);
|
|
825
|
-
|
|
840
|
+
|
|
826
841
|
return cell;
|
|
827
842
|
}
|
|
828
|
-
|
|
843
|
+
|
|
829
844
|
nextColumn(){
|
|
830
845
|
var index = this.table.columnManager.findColumnIndex(this);
|
|
831
846
|
return index > -1 ? this._nextVisibleColumn(index + 1) : false;
|
|
832
847
|
}
|
|
833
|
-
|
|
848
|
+
|
|
834
849
|
_nextVisibleColumn(index){
|
|
835
850
|
var column = this.table.columnManager.getColumnByIndex(index);
|
|
836
851
|
return !column || column.visible ? column : this._nextVisibleColumn(index + 1);
|
|
837
852
|
}
|
|
838
|
-
|
|
853
|
+
|
|
839
854
|
prevColumn(){
|
|
840
855
|
var index = this.table.columnManager.findColumnIndex(this);
|
|
841
856
|
return index > -1 ? this._prevVisibleColumn(index - 1) : false;
|
|
842
857
|
}
|
|
843
|
-
|
|
858
|
+
|
|
844
859
|
_prevVisibleColumn(index){
|
|
845
860
|
var column = this.table.columnManager.getColumnByIndex(index);
|
|
846
861
|
return !column || column.visible ? column : this._prevVisibleColumn(index - 1);
|
|
847
862
|
}
|
|
848
|
-
|
|
863
|
+
|
|
849
864
|
reinitializeWidth(force){
|
|
850
865
|
this.widthFixed = false;
|
|
851
|
-
|
|
866
|
+
|
|
852
867
|
//set width if present
|
|
853
868
|
if(typeof this.definition.width !== "undefined" && !force){
|
|
854
869
|
// maxInitialWidth ignored here as width specified
|
|
855
870
|
this.setWidth(this.definition.width);
|
|
856
871
|
}
|
|
857
|
-
|
|
872
|
+
|
|
858
873
|
this.dispatch("column-width-fit-before", this);
|
|
859
|
-
|
|
874
|
+
|
|
860
875
|
this.fitToData(force);
|
|
861
|
-
|
|
876
|
+
|
|
862
877
|
this.dispatch("column-width-fit-after", this);
|
|
863
878
|
}
|
|
864
|
-
|
|
879
|
+
|
|
865
880
|
//set column width to maximum cell width for non group columns
|
|
866
881
|
fitToData(force){
|
|
867
882
|
if(this.isGroup){
|
|
868
883
|
return;
|
|
869
884
|
}
|
|
870
|
-
|
|
885
|
+
|
|
871
886
|
if(!this.widthFixed){
|
|
872
887
|
this.element.style.width = "";
|
|
873
|
-
|
|
888
|
+
|
|
874
889
|
this.cells.forEach((cell) => {
|
|
875
890
|
cell.clearWidth();
|
|
876
891
|
});
|
|
877
892
|
}
|
|
878
|
-
|
|
893
|
+
|
|
879
894
|
var maxWidth = this.element.offsetWidth;
|
|
880
|
-
|
|
895
|
+
|
|
881
896
|
if(!this.width || !this.widthFixed){
|
|
882
897
|
this.cells.forEach((cell) => {
|
|
883
898
|
var width = cell.getWidth();
|
|
884
|
-
|
|
899
|
+
|
|
885
900
|
if(width > maxWidth){
|
|
886
901
|
maxWidth = width;
|
|
887
902
|
}
|
|
888
903
|
});
|
|
889
|
-
|
|
904
|
+
|
|
890
905
|
if(maxWidth){
|
|
891
906
|
var setTo = maxWidth + 1;
|
|
892
907
|
if (this.maxInitialWidth && !force) {
|
|
@@ -896,27 +911,27 @@ class Column extends CoreFeature{
|
|
|
896
911
|
}
|
|
897
912
|
}
|
|
898
913
|
}
|
|
899
|
-
|
|
914
|
+
|
|
900
915
|
updateDefinition(updates){
|
|
901
916
|
var definition;
|
|
902
|
-
|
|
917
|
+
|
|
903
918
|
if(!this.isGroup){
|
|
904
919
|
if(!this.parent.isGroup){
|
|
905
920
|
definition = Object.assign({}, this.getDefinition());
|
|
906
921
|
definition = Object.assign(definition, updates);
|
|
907
|
-
|
|
922
|
+
|
|
908
923
|
return this.table.columnManager.addColumn(definition, false, this)
|
|
909
924
|
.then((column) => {
|
|
910
|
-
|
|
925
|
+
|
|
911
926
|
if(definition.field == this.field){
|
|
912
927
|
this.field = false; //clear field name to prevent deletion of duplicate column from arrays
|
|
913
928
|
}
|
|
914
|
-
|
|
929
|
+
|
|
915
930
|
return this.delete()
|
|
916
931
|
.then(() => {
|
|
917
932
|
return column.getComponent();
|
|
918
933
|
});
|
|
919
|
-
|
|
934
|
+
|
|
920
935
|
});
|
|
921
936
|
}else{
|
|
922
937
|
console.error("Column Update Error - The updateDefinition function is only available on ungrouped columns");
|
|
@@ -927,29 +942,29 @@ class Column extends CoreFeature{
|
|
|
927
942
|
return Promise.reject("Column Update Error - The updateDefinition function is only available on columns, not column groups");
|
|
928
943
|
}
|
|
929
944
|
}
|
|
930
|
-
|
|
945
|
+
|
|
931
946
|
deleteCell(cell){
|
|
932
947
|
var index = this.cells.indexOf(cell);
|
|
933
|
-
|
|
948
|
+
|
|
934
949
|
if(index > -1){
|
|
935
950
|
this.cells.splice(index, 1);
|
|
936
951
|
}
|
|
937
952
|
}
|
|
938
|
-
|
|
953
|
+
|
|
939
954
|
//////////////// Object Generation /////////////////
|
|
940
955
|
getComponent(){
|
|
941
956
|
if(!this.component){
|
|
942
957
|
this.component = new ColumnComponent(this);
|
|
943
958
|
}
|
|
944
|
-
|
|
959
|
+
|
|
945
960
|
return this.component;
|
|
946
961
|
}
|
|
947
|
-
|
|
962
|
+
|
|
948
963
|
getPosition(){
|
|
949
964
|
return this.table.columnManager.getVisibleColumnsByIndex().indexOf(this) + 1;
|
|
950
965
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
Column.
|
|
954
|
-
|
|
955
|
-
|
|
966
|
+
|
|
967
|
+
getParentComponent(){
|
|
968
|
+
return this.parent instanceof Column ? this.parent.getComponent() : false;
|
|
969
|
+
}
|
|
970
|
+
}
|