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