tabulator-tables 5.4.3 → 5.4.4
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 +0 -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 +0 -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 +0 -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 +0 -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 +0 -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 +0 -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 +0 -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 +0 -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 +102 -107
- 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 +0 -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 +0 -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/jquery_wrapper.js +55 -55
- package/dist/js/tabulator.js +25847 -25711
- 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 +25926 -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 +730 -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 +1112 -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 +76 -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 +19 -19
- package/src/js/core/rendering/renderers/BasicVertical.js +79 -78
- package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +577 -577
- package/src/js/core/rendering/renderers/VirtualDomVertical.js +579 -579
- 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 +85 -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 +98 -98
- package/src/js/modules/Download/defaults/downloaders.js +14 -14
- package/src/js/modules/Edit/Edit.js +735 -736
- package/src/js/modules/Edit/List.js +1037 -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 +623 -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 +892 -892
- package/src/js/modules/Filter/defaults/filters.js +107 -107
- package/src/js/modules/Format/Format.js +212 -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 +36 -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 +66 -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 +325 -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 +458 -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 +345 -345
- package/src/js/modules/SelectRow/SelectRow.js +446 -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 +1464 -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 +284 -284
- package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +544 -544
- package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +574 -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 +252 -252
- package/src/scss/themes/bulma/variables.scss +197 -197
- package/src/scss/themes/materialize/tabulator_materialize.scss +265 -265
- package/src/scss/themes/materialize/variables.scss +70 -70
- package/src/scss/themes/semanticui/tabulator_semanticui.scss +561 -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 +158 -158
- package/src/scss/themes/tabulator_modern.scss +231 -231
- package/src/scss/themes/tabulator_simple.scss +102 -102
- package/src/scss/themes/tabulator_site.scss +189 -189
|
@@ -1,578 +1,578 @@
|
|
|
1
|
-
import Renderer from '../Renderer.js';
|
|
2
|
-
|
|
3
|
-
export default class VirtualDomHorizontal extends Renderer{
|
|
4
|
-
constructor(table){
|
|
5
|
-
super(table);
|
|
6
|
-
|
|
7
|
-
this.leftCol = 0;
|
|
8
|
-
this.rightCol = 0;
|
|
9
|
-
this.scrollLeft = 0;
|
|
10
|
-
|
|
11
|
-
this.vDomScrollPosLeft = 0;
|
|
12
|
-
this.vDomScrollPosRight = 0;
|
|
13
|
-
|
|
14
|
-
this.vDomPadLeft = 0;
|
|
15
|
-
this.vDomPadRight = 0;
|
|
16
|
-
|
|
17
|
-
this.fitDataColAvg = 0;
|
|
18
|
-
|
|
19
|
-
this.windowBuffer = 200; //pixel margin to make column visible before it is shown on screen
|
|
20
|
-
|
|
21
|
-
this.visibleRows = null;
|
|
22
|
-
|
|
23
|
-
this.initialized = false;
|
|
24
|
-
this.isFitData = false;
|
|
25
|
-
|
|
26
|
-
this.columns = [];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
initialize(){
|
|
30
|
-
this.compatibilityCheck();
|
|
31
|
-
this.layoutCheck();
|
|
32
|
-
this.vertScrollListen();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
compatibilityCheck(){
|
|
36
|
-
if(this.options("layout") == "fitDataTable"){
|
|
37
|
-
console.warn("Horizontal Virtual DOM is not compatible with fitDataTable layout mode");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if(this.options("responsiveLayout")){
|
|
41
|
-
console.warn("Horizontal Virtual DOM is not compatible with responsive columns");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if(this.options("rtl")){
|
|
45
|
-
console.warn("Horizontal Virtual DOM is not currently compatible with RTL text direction");
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
layoutCheck(){
|
|
50
|
-
this.isFitData = this.options("layout").startsWith('fitData');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
vertScrollListen(){
|
|
54
|
-
this.subscribe("scroll-vertical", this.clearVisRowCache.bind(this));
|
|
55
|
-
this.subscribe("data-refreshed", this.clearVisRowCache.bind(this));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
clearVisRowCache(){
|
|
59
|
-
this.visibleRows = null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
//////////////////////////////////////
|
|
63
|
-
///////// Public Functions ///////////
|
|
64
|
-
//////////////////////////////////////
|
|
65
|
-
|
|
66
|
-
renderColumns(row, force){
|
|
67
|
-
this.dataChange();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
scrollColumns(left, dir){
|
|
72
|
-
if(this.scrollLeft != left){
|
|
73
|
-
this.scrollLeft = left;
|
|
74
|
-
|
|
75
|
-
this.scroll(left - (this.vDomScrollPosLeft + this.windowBuffer));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
calcWindowBuffer(){
|
|
80
|
-
var buffer = this.elementVertical.clientWidth;
|
|
81
|
-
|
|
82
|
-
this.table.columnManager.columnsByIndex.forEach((column) => {
|
|
83
|
-
if(column.visible){
|
|
84
|
-
var width = column.getWidth();
|
|
85
|
-
|
|
86
|
-
if(width > buffer){
|
|
87
|
-
buffer = width;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
this.windowBuffer = buffer * 2;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
rerenderColumns(update, blockRedraw){
|
|
96
|
-
var old = {
|
|
97
|
-
cols:this.columns,
|
|
98
|
-
leftCol:this.leftCol,
|
|
99
|
-
rightCol:this.rightCol,
|
|
100
|
-
},
|
|
101
|
-
colPos = 0;
|
|
102
|
-
|
|
103
|
-
if(update && !this.initialized){
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
this.clear();
|
|
108
|
-
|
|
109
|
-
this.calcWindowBuffer();
|
|
110
|
-
|
|
111
|
-
this.scrollLeft = this.elementVertical.scrollLeft;
|
|
112
|
-
|
|
113
|
-
this.vDomScrollPosLeft = this.scrollLeft - this.windowBuffer;
|
|
114
|
-
this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;
|
|
115
|
-
|
|
116
|
-
this.table.columnManager.columnsByIndex.forEach((column) => {
|
|
117
|
-
var config = {},
|
|
118
|
-
width;
|
|
119
|
-
|
|
120
|
-
if(column.visible){
|
|
121
|
-
if(!column.modules.frozen){
|
|
122
|
-
width = column.getWidth();
|
|
123
|
-
|
|
124
|
-
config.leftPos = colPos;
|
|
125
|
-
config.rightPos = colPos + width;
|
|
126
|
-
|
|
127
|
-
config.width = width;
|
|
128
|
-
|
|
129
|
-
if (this.isFitData) {
|
|
130
|
-
config.fitDataCheck = column.modules.vdomHoz ? column.modules.vdomHoz.fitDataCheck : true;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if((colPos + width > this.vDomScrollPosLeft) && (colPos < this.vDomScrollPosRight)){
|
|
134
|
-
//column is visible
|
|
135
|
-
|
|
136
|
-
if(this.leftCol == -1){
|
|
137
|
-
this.leftCol = this.columns.length;
|
|
138
|
-
this.vDomPadLeft = colPos;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this.rightCol = this.columns.length;
|
|
142
|
-
}else{
|
|
143
|
-
// column is hidden
|
|
144
|
-
if(this.leftCol !== -1){
|
|
145
|
-
this.vDomPadRight += width;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
this.columns.push(column);
|
|
150
|
-
|
|
151
|
-
column.modules.vdomHoz = config;
|
|
152
|
-
|
|
153
|
-
colPos += width;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
|
|
159
|
-
this.tableElement.style.paddingRight = this.vDomPadRight + "px";
|
|
160
|
-
|
|
161
|
-
this.initialized = true;
|
|
162
|
-
|
|
163
|
-
if(!blockRedraw){
|
|
164
|
-
if(!update || this.reinitChanged(old)){
|
|
165
|
-
this.reinitializeRows();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
this.elementVertical.scrollLeft = this.scrollLeft;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
renderRowCells(row){
|
|
173
|
-
if(this.initialized){
|
|
174
|
-
this.initializeRow(row);
|
|
175
|
-
}else{
|
|
176
|
-
row.cells.forEach((cell) => {
|
|
177
|
-
row.element.appendChild(cell.getElement());
|
|
178
|
-
cell.cellRendered();
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
rerenderRowCells(row, force){
|
|
184
|
-
this.reinitializeRow(row, force);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
reinitializeColumnWidths(columns){
|
|
188
|
-
for(let i = this.leftCol; i <= this.rightCol; i++){
|
|
189
|
-
this.columns[i].reinitializeWidth();
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
//////////////////////////////////////
|
|
194
|
-
//////// Internal Rendering //////////
|
|
195
|
-
//////////////////////////////////////
|
|
196
|
-
|
|
197
|
-
deinitialize(){
|
|
198
|
-
this.initialized = false;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
clear(){
|
|
202
|
-
this.columns = [];
|
|
203
|
-
|
|
204
|
-
this.leftCol = -1;
|
|
205
|
-
this.rightCol = 0;
|
|
206
|
-
|
|
207
|
-
this.vDomScrollPosLeft = 0;
|
|
208
|
-
this.vDomScrollPosRight = 0;
|
|
209
|
-
this.vDomPadLeft = 0;
|
|
210
|
-
this.vDomPadRight = 0;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
dataChange(){
|
|
214
|
-
var change = false,
|
|
215
|
-
row, rowEl;
|
|
216
|
-
|
|
217
|
-
if(this.isFitData){
|
|
218
|
-
this.table.columnManager.columnsByIndex.forEach((column) => {
|
|
219
|
-
if(!column.definition.width && column.visible){
|
|
220
|
-
change = true;
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
if(change && this.table.rowManager.getDisplayRows().length){
|
|
225
|
-
this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;
|
|
226
|
-
|
|
227
|
-
row = this.chain("rows-sample", [1], [], () => {
|
|
228
|
-
return this.table.rowManager.getDisplayRows();
|
|
229
|
-
})[0];
|
|
230
|
-
|
|
231
|
-
if(row){
|
|
232
|
-
rowEl = row.getElement();
|
|
233
|
-
|
|
234
|
-
row.generateCells();
|
|
235
|
-
|
|
236
|
-
this.tableElement.appendChild(rowEl);
|
|
237
|
-
|
|
238
|
-
for(let colEnd = 0; colEnd < row.cells.length; colEnd++){
|
|
239
|
-
let cell = row.cells[colEnd];
|
|
240
|
-
rowEl.appendChild(cell.getElement());
|
|
241
|
-
|
|
242
|
-
cell.column.reinitializeWidth();
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
rowEl.parentNode.removeChild(rowEl);
|
|
246
|
-
|
|
247
|
-
this.rerenderColumns(false, true);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}else{
|
|
251
|
-
if(this.options("layout") === "fitColumns"){
|
|
252
|
-
this.layoutRefresh();
|
|
253
|
-
this.rerenderColumns(false, true);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
reinitChanged(old){
|
|
259
|
-
var match = true;
|
|
260
|
-
|
|
261
|
-
if(old.cols.length !== this.columns.length || old.leftCol !== this.leftCol || old.rightCol !== this.rightCol){
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
old.cols.forEach((col, i) => {
|
|
266
|
-
if(col !== this.columns[i]){
|
|
267
|
-
match = false;
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
return !match;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
reinitializeRows(){
|
|
275
|
-
var visibleRows = this.getVisibleRows(),
|
|
276
|
-
otherRows = this.table.rowManager.getRows().filter(row => !visibleRows.includes(row));
|
|
277
|
-
|
|
278
|
-
visibleRows.forEach((row) => {
|
|
279
|
-
this.reinitializeRow(row, true);
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
otherRows.forEach((row) =>{
|
|
283
|
-
row.deinitialize();
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
getVisibleRows(){
|
|
288
|
-
if (!this.visibleRows){
|
|
289
|
-
this.visibleRows = this.table.rowManager.getVisibleRows();
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
return this.visibleRows;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
scroll(diff){
|
|
296
|
-
this.vDomScrollPosLeft += diff;
|
|
297
|
-
this.vDomScrollPosRight += diff;
|
|
298
|
-
|
|
299
|
-
if(Math.abs(diff) > (this.windowBuffer / 2)){
|
|
300
|
-
this.rerenderColumns();
|
|
301
|
-
}else{
|
|
302
|
-
if(diff > 0){
|
|
303
|
-
//scroll right
|
|
304
|
-
this.addColRight();
|
|
305
|
-
this.removeColLeft();
|
|
306
|
-
}else{
|
|
307
|
-
//scroll left
|
|
308
|
-
this.addColLeft();
|
|
309
|
-
this.removeColRight();
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
colPositionAdjust (start, end, diff){
|
|
315
|
-
for(let i = start; i < end; i++){
|
|
316
|
-
let column = this.columns[i];
|
|
317
|
-
|
|
318
|
-
column.modules.vdomHoz.leftPos += diff;
|
|
319
|
-
column.modules.vdomHoz.rightPos += diff;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
addColRight(){
|
|
324
|
-
var changes = false,
|
|
325
|
-
working = true;
|
|
326
|
-
|
|
327
|
-
while(working){
|
|
328
|
-
|
|
329
|
-
let column = this.columns[this.rightCol + 1];
|
|
330
|
-
|
|
331
|
-
if(column){
|
|
332
|
-
if(column.modules.vdomHoz.leftPos <= this.vDomScrollPosRight){
|
|
333
|
-
changes = true;
|
|
334
|
-
|
|
335
|
-
this.getVisibleRows().forEach((row) => {
|
|
336
|
-
if(row.type !== "group"){
|
|
337
|
-
var cell = row.getCell(column);
|
|
338
|
-
row.getElement().insertBefore(cell.getElement(), row.getCell(this.columns[this.rightCol]).getElement().nextSibling);
|
|
339
|
-
cell.cellRendered();
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
this.fitDataColActualWidthCheck(column);
|
|
344
|
-
|
|
345
|
-
this.rightCol++; // Don't move this below the >= check below
|
|
346
|
-
|
|
347
|
-
this.getVisibleRows().forEach((row) => {
|
|
348
|
-
if(row.type !== "group"){
|
|
349
|
-
row.modules.vdomHoz.rightCol = this.rightCol;
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
if(this.rightCol >= (this.columns.length - 1)){
|
|
354
|
-
this.vDomPadRight = 0;
|
|
355
|
-
}else{
|
|
356
|
-
this.vDomPadRight -= column.getWidth();
|
|
357
|
-
}
|
|
358
|
-
}else{
|
|
359
|
-
working = false;
|
|
360
|
-
}
|
|
361
|
-
}else{
|
|
362
|
-
working = false;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
if(changes){
|
|
367
|
-
this.tableElement.style.paddingRight = this.vDomPadRight + "px";
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
addColLeft(){
|
|
372
|
-
var changes = false,
|
|
373
|
-
working = true;
|
|
374
|
-
|
|
375
|
-
while(working){
|
|
376
|
-
let column = this.columns[this.leftCol - 1];
|
|
377
|
-
|
|
378
|
-
if(column){
|
|
379
|
-
if(column.modules.vdomHoz.rightPos >= this.vDomScrollPosLeft){
|
|
380
|
-
changes = true;
|
|
381
|
-
|
|
382
|
-
this.getVisibleRows().forEach((row) => {
|
|
383
|
-
if(row.type !== "group"){
|
|
384
|
-
var cell = row.getCell(column);
|
|
385
|
-
row.getElement().insertBefore(cell.getElement(), row.getCell(this.columns[this.leftCol]).getElement());
|
|
386
|
-
cell.cellRendered();
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
this.leftCol--; // don't move this below the <= check below
|
|
391
|
-
|
|
392
|
-
this.getVisibleRows().forEach((row) => {
|
|
393
|
-
if(row.type !== "group"){
|
|
394
|
-
row.modules.vdomHoz.leftCol = this.leftCol;
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
if(this.leftCol <= 0){ // replicating logic in addColRight
|
|
399
|
-
this.vDomPadLeft = 0;
|
|
400
|
-
}else{
|
|
401
|
-
this.vDomPadLeft -= column.getWidth();
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
let diff = this.fitDataColActualWidthCheck(column);
|
|
405
|
-
|
|
406
|
-
if(diff){
|
|
407
|
-
this.scrollLeft = this.elementVertical.scrollLeft = this.elementVertical.scrollLeft + diff;
|
|
408
|
-
this.vDomPadRight -= diff;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
}else{
|
|
412
|
-
working = false;
|
|
413
|
-
}
|
|
414
|
-
}else{
|
|
415
|
-
working = false;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
if(changes){
|
|
420
|
-
this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
removeColRight(){
|
|
425
|
-
var changes = false,
|
|
426
|
-
working = true;
|
|
427
|
-
|
|
428
|
-
while(working){
|
|
429
|
-
let column = this.columns[this.rightCol];
|
|
430
|
-
|
|
431
|
-
if(column){
|
|
432
|
-
if(column.modules.vdomHoz.leftPos > this.vDomScrollPosRight){
|
|
433
|
-
changes = true;
|
|
434
|
-
|
|
435
|
-
this.getVisibleRows().forEach((row) => {
|
|
436
|
-
if(row.type !== "group"){
|
|
437
|
-
var cell = row.getCell(column);
|
|
438
|
-
|
|
439
|
-
try {
|
|
440
|
-
row.getElement().removeChild(cell.getElement());
|
|
441
|
-
} catch (ex) {
|
|
442
|
-
console.warn("Could not removeColRight", ex.message);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
this.vDomPadRight += column.getWidth();
|
|
448
|
-
this.rightCol --;
|
|
449
|
-
|
|
450
|
-
this.getVisibleRows().forEach((row) => {
|
|
451
|
-
if(row.type !== "group"){
|
|
452
|
-
row.modules.vdomHoz.rightCol = this.rightCol;
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
}else{
|
|
456
|
-
working = false;
|
|
457
|
-
}
|
|
458
|
-
}else{
|
|
459
|
-
working = false;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
if(changes){
|
|
464
|
-
this.tableElement.style.paddingRight = this.vDomPadRight + "px";
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
removeColLeft(){
|
|
469
|
-
var changes = false,
|
|
470
|
-
working = true;
|
|
471
|
-
|
|
472
|
-
while(working){
|
|
473
|
-
let column = this.columns[this.leftCol];
|
|
474
|
-
|
|
475
|
-
if(column){
|
|
476
|
-
if(column.modules.vdomHoz.rightPos < this.vDomScrollPosLeft){
|
|
477
|
-
changes = true;
|
|
478
|
-
|
|
479
|
-
this.getVisibleRows().forEach((row) => {
|
|
480
|
-
if(row.type !== "group"){
|
|
481
|
-
var cell = row.getCell(column);
|
|
482
|
-
|
|
483
|
-
try {
|
|
484
|
-
row.getElement().removeChild(cell.getElement());
|
|
485
|
-
} catch (ex) {
|
|
486
|
-
console.warn("Could not removeColLeft", ex.message);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
this.vDomPadLeft += column.getWidth();
|
|
492
|
-
this.leftCol ++;
|
|
493
|
-
|
|
494
|
-
this.getVisibleRows().forEach((row) => {
|
|
495
|
-
if(row.type !== "group"){
|
|
496
|
-
row.modules.vdomHoz.leftCol = this.leftCol;
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
}else{
|
|
500
|
-
working = false;
|
|
501
|
-
}
|
|
502
|
-
}else{
|
|
503
|
-
working = false;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
if(changes){
|
|
508
|
-
this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
fitDataColActualWidthCheck(column){
|
|
513
|
-
var newWidth, widthDiff;
|
|
514
|
-
|
|
515
|
-
if(column.modules.vdomHoz.fitDataCheck){
|
|
516
|
-
column.reinitializeWidth();
|
|
517
|
-
|
|
518
|
-
newWidth = column.getWidth();
|
|
519
|
-
widthDiff = newWidth - column.modules.vdomHoz.width;
|
|
520
|
-
|
|
521
|
-
if(widthDiff){
|
|
522
|
-
column.modules.vdomHoz.rightPos += widthDiff;
|
|
523
|
-
column.modules.vdomHoz.width = newWidth;
|
|
524
|
-
this.colPositionAdjust(this.columns.indexOf(column) + 1, this.columns.length, widthDiff);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
column.modules.vdomHoz.fitDataCheck = false;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
return widthDiff;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
initializeRow(row){
|
|
534
|
-
if(row.type !== "group"){
|
|
535
|
-
row.modules.vdomHoz = {
|
|
536
|
-
leftCol:this.leftCol,
|
|
537
|
-
rightCol:this.rightCol,
|
|
538
|
-
};
|
|
539
|
-
|
|
540
|
-
if(this.table.modules.frozenColumns){
|
|
541
|
-
this.table.modules.frozenColumns.leftColumns.forEach((column) => {
|
|
542
|
-
this.appendCell(row, column);
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
for(let i = this.leftCol; i <= this.rightCol; i++){
|
|
547
|
-
this.appendCell(row, this.columns[i]);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
if(this.table.modules.frozenColumns){
|
|
551
|
-
this.table.modules.frozenColumns.rightColumns.forEach((column) => {
|
|
552
|
-
this.appendCell(row, column);
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
appendCell(row, column){
|
|
559
|
-
if(column && column.visible){
|
|
560
|
-
let cell = row.getCell(column);
|
|
561
|
-
|
|
562
|
-
row.getElement().appendChild(cell.getElement());
|
|
563
|
-
cell.cellRendered();
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
reinitializeRow(row, force){
|
|
568
|
-
if(row.type !== "group"){
|
|
569
|
-
if(force || !row.modules.vdomHoz || row.modules.vdomHoz.leftCol !== this.leftCol || row.modules.vdomHoz.rightCol !== this.rightCol){
|
|
570
|
-
|
|
571
|
-
var rowEl = row.getElement();
|
|
572
|
-
while(rowEl.firstChild) rowEl.removeChild(rowEl.firstChild);
|
|
573
|
-
|
|
574
|
-
this.initializeRow(row);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
1
|
+
import Renderer from '../Renderer.js';
|
|
2
|
+
|
|
3
|
+
export default class VirtualDomHorizontal extends Renderer{
|
|
4
|
+
constructor(table){
|
|
5
|
+
super(table);
|
|
6
|
+
|
|
7
|
+
this.leftCol = 0;
|
|
8
|
+
this.rightCol = 0;
|
|
9
|
+
this.scrollLeft = 0;
|
|
10
|
+
|
|
11
|
+
this.vDomScrollPosLeft = 0;
|
|
12
|
+
this.vDomScrollPosRight = 0;
|
|
13
|
+
|
|
14
|
+
this.vDomPadLeft = 0;
|
|
15
|
+
this.vDomPadRight = 0;
|
|
16
|
+
|
|
17
|
+
this.fitDataColAvg = 0;
|
|
18
|
+
|
|
19
|
+
this.windowBuffer = 200; //pixel margin to make column visible before it is shown on screen
|
|
20
|
+
|
|
21
|
+
this.visibleRows = null;
|
|
22
|
+
|
|
23
|
+
this.initialized = false;
|
|
24
|
+
this.isFitData = false;
|
|
25
|
+
|
|
26
|
+
this.columns = [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
initialize(){
|
|
30
|
+
this.compatibilityCheck();
|
|
31
|
+
this.layoutCheck();
|
|
32
|
+
this.vertScrollListen();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
compatibilityCheck(){
|
|
36
|
+
if(this.options("layout") == "fitDataTable"){
|
|
37
|
+
console.warn("Horizontal Virtual DOM is not compatible with fitDataTable layout mode");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if(this.options("responsiveLayout")){
|
|
41
|
+
console.warn("Horizontal Virtual DOM is not compatible with responsive columns");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if(this.options("rtl")){
|
|
45
|
+
console.warn("Horizontal Virtual DOM is not currently compatible with RTL text direction");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
layoutCheck(){
|
|
50
|
+
this.isFitData = this.options("layout").startsWith('fitData');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
vertScrollListen(){
|
|
54
|
+
this.subscribe("scroll-vertical", this.clearVisRowCache.bind(this));
|
|
55
|
+
this.subscribe("data-refreshed", this.clearVisRowCache.bind(this));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
clearVisRowCache(){
|
|
59
|
+
this.visibleRows = null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//////////////////////////////////////
|
|
63
|
+
///////// Public Functions ///////////
|
|
64
|
+
//////////////////////////////////////
|
|
65
|
+
|
|
66
|
+
renderColumns(row, force){
|
|
67
|
+
this.dataChange();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
scrollColumns(left, dir){
|
|
72
|
+
if(this.scrollLeft != left){
|
|
73
|
+
this.scrollLeft = left;
|
|
74
|
+
|
|
75
|
+
this.scroll(left - (this.vDomScrollPosLeft + this.windowBuffer));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
calcWindowBuffer(){
|
|
80
|
+
var buffer = this.elementVertical.clientWidth;
|
|
81
|
+
|
|
82
|
+
this.table.columnManager.columnsByIndex.forEach((column) => {
|
|
83
|
+
if(column.visible){
|
|
84
|
+
var width = column.getWidth();
|
|
85
|
+
|
|
86
|
+
if(width > buffer){
|
|
87
|
+
buffer = width;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
this.windowBuffer = buffer * 2;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
rerenderColumns(update, blockRedraw){
|
|
96
|
+
var old = {
|
|
97
|
+
cols:this.columns,
|
|
98
|
+
leftCol:this.leftCol,
|
|
99
|
+
rightCol:this.rightCol,
|
|
100
|
+
},
|
|
101
|
+
colPos = 0;
|
|
102
|
+
|
|
103
|
+
if(update && !this.initialized){
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.clear();
|
|
108
|
+
|
|
109
|
+
this.calcWindowBuffer();
|
|
110
|
+
|
|
111
|
+
this.scrollLeft = this.elementVertical.scrollLeft;
|
|
112
|
+
|
|
113
|
+
this.vDomScrollPosLeft = this.scrollLeft - this.windowBuffer;
|
|
114
|
+
this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;
|
|
115
|
+
|
|
116
|
+
this.table.columnManager.columnsByIndex.forEach((column) => {
|
|
117
|
+
var config = {},
|
|
118
|
+
width;
|
|
119
|
+
|
|
120
|
+
if(column.visible){
|
|
121
|
+
if(!column.modules.frozen){
|
|
122
|
+
width = column.getWidth();
|
|
123
|
+
|
|
124
|
+
config.leftPos = colPos;
|
|
125
|
+
config.rightPos = colPos + width;
|
|
126
|
+
|
|
127
|
+
config.width = width;
|
|
128
|
+
|
|
129
|
+
if (this.isFitData) {
|
|
130
|
+
config.fitDataCheck = column.modules.vdomHoz ? column.modules.vdomHoz.fitDataCheck : true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if((colPos + width > this.vDomScrollPosLeft) && (colPos < this.vDomScrollPosRight)){
|
|
134
|
+
//column is visible
|
|
135
|
+
|
|
136
|
+
if(this.leftCol == -1){
|
|
137
|
+
this.leftCol = this.columns.length;
|
|
138
|
+
this.vDomPadLeft = colPos;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.rightCol = this.columns.length;
|
|
142
|
+
}else{
|
|
143
|
+
// column is hidden
|
|
144
|
+
if(this.leftCol !== -1){
|
|
145
|
+
this.vDomPadRight += width;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
this.columns.push(column);
|
|
150
|
+
|
|
151
|
+
column.modules.vdomHoz = config;
|
|
152
|
+
|
|
153
|
+
colPos += width;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
|
|
159
|
+
this.tableElement.style.paddingRight = this.vDomPadRight + "px";
|
|
160
|
+
|
|
161
|
+
this.initialized = true;
|
|
162
|
+
|
|
163
|
+
if(!blockRedraw){
|
|
164
|
+
if(!update || this.reinitChanged(old)){
|
|
165
|
+
this.reinitializeRows();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
this.elementVertical.scrollLeft = this.scrollLeft;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
renderRowCells(row){
|
|
173
|
+
if(this.initialized){
|
|
174
|
+
this.initializeRow(row);
|
|
175
|
+
}else{
|
|
176
|
+
row.cells.forEach((cell) => {
|
|
177
|
+
row.element.appendChild(cell.getElement());
|
|
178
|
+
cell.cellRendered();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
rerenderRowCells(row, force){
|
|
184
|
+
this.reinitializeRow(row, force);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
reinitializeColumnWidths(columns){
|
|
188
|
+
for(let i = this.leftCol; i <= this.rightCol; i++){
|
|
189
|
+
this.columns[i].reinitializeWidth();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
//////////////////////////////////////
|
|
194
|
+
//////// Internal Rendering //////////
|
|
195
|
+
//////////////////////////////////////
|
|
196
|
+
|
|
197
|
+
deinitialize(){
|
|
198
|
+
this.initialized = false;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
clear(){
|
|
202
|
+
this.columns = [];
|
|
203
|
+
|
|
204
|
+
this.leftCol = -1;
|
|
205
|
+
this.rightCol = 0;
|
|
206
|
+
|
|
207
|
+
this.vDomScrollPosLeft = 0;
|
|
208
|
+
this.vDomScrollPosRight = 0;
|
|
209
|
+
this.vDomPadLeft = 0;
|
|
210
|
+
this.vDomPadRight = 0;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
dataChange(){
|
|
214
|
+
var change = false,
|
|
215
|
+
row, rowEl;
|
|
216
|
+
|
|
217
|
+
if(this.isFitData){
|
|
218
|
+
this.table.columnManager.columnsByIndex.forEach((column) => {
|
|
219
|
+
if(!column.definition.width && column.visible){
|
|
220
|
+
change = true;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
if(change && this.table.rowManager.getDisplayRows().length){
|
|
225
|
+
this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;
|
|
226
|
+
|
|
227
|
+
row = this.chain("rows-sample", [1], [], () => {
|
|
228
|
+
return this.table.rowManager.getDisplayRows();
|
|
229
|
+
})[0];
|
|
230
|
+
|
|
231
|
+
if(row){
|
|
232
|
+
rowEl = row.getElement();
|
|
233
|
+
|
|
234
|
+
row.generateCells();
|
|
235
|
+
|
|
236
|
+
this.tableElement.appendChild(rowEl);
|
|
237
|
+
|
|
238
|
+
for(let colEnd = 0; colEnd < row.cells.length; colEnd++){
|
|
239
|
+
let cell = row.cells[colEnd];
|
|
240
|
+
rowEl.appendChild(cell.getElement());
|
|
241
|
+
|
|
242
|
+
cell.column.reinitializeWidth();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
rowEl.parentNode.removeChild(rowEl);
|
|
246
|
+
|
|
247
|
+
this.rerenderColumns(false, true);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}else{
|
|
251
|
+
if(this.options("layout") === "fitColumns"){
|
|
252
|
+
this.layoutRefresh();
|
|
253
|
+
this.rerenderColumns(false, true);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
reinitChanged(old){
|
|
259
|
+
var match = true;
|
|
260
|
+
|
|
261
|
+
if(old.cols.length !== this.columns.length || old.leftCol !== this.leftCol || old.rightCol !== this.rightCol){
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
old.cols.forEach((col, i) => {
|
|
266
|
+
if(col !== this.columns[i]){
|
|
267
|
+
match = false;
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
return !match;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
reinitializeRows(){
|
|
275
|
+
var visibleRows = this.getVisibleRows(),
|
|
276
|
+
otherRows = this.table.rowManager.getRows().filter(row => !visibleRows.includes(row));
|
|
277
|
+
|
|
278
|
+
visibleRows.forEach((row) => {
|
|
279
|
+
this.reinitializeRow(row, true);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
otherRows.forEach((row) =>{
|
|
283
|
+
row.deinitialize();
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
getVisibleRows(){
|
|
288
|
+
if (!this.visibleRows){
|
|
289
|
+
this.visibleRows = this.table.rowManager.getVisibleRows();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return this.visibleRows;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
scroll(diff){
|
|
296
|
+
this.vDomScrollPosLeft += diff;
|
|
297
|
+
this.vDomScrollPosRight += diff;
|
|
298
|
+
|
|
299
|
+
if(Math.abs(diff) > (this.windowBuffer / 2)){
|
|
300
|
+
this.rerenderColumns();
|
|
301
|
+
}else{
|
|
302
|
+
if(diff > 0){
|
|
303
|
+
//scroll right
|
|
304
|
+
this.addColRight();
|
|
305
|
+
this.removeColLeft();
|
|
306
|
+
}else{
|
|
307
|
+
//scroll left
|
|
308
|
+
this.addColLeft();
|
|
309
|
+
this.removeColRight();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
colPositionAdjust (start, end, diff){
|
|
315
|
+
for(let i = start; i < end; i++){
|
|
316
|
+
let column = this.columns[i];
|
|
317
|
+
|
|
318
|
+
column.modules.vdomHoz.leftPos += diff;
|
|
319
|
+
column.modules.vdomHoz.rightPos += diff;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
addColRight(){
|
|
324
|
+
var changes = false,
|
|
325
|
+
working = true;
|
|
326
|
+
|
|
327
|
+
while(working){
|
|
328
|
+
|
|
329
|
+
let column = this.columns[this.rightCol + 1];
|
|
330
|
+
|
|
331
|
+
if(column){
|
|
332
|
+
if(column.modules.vdomHoz.leftPos <= this.vDomScrollPosRight){
|
|
333
|
+
changes = true;
|
|
334
|
+
|
|
335
|
+
this.getVisibleRows().forEach((row) => {
|
|
336
|
+
if(row.type !== "group"){
|
|
337
|
+
var cell = row.getCell(column);
|
|
338
|
+
row.getElement().insertBefore(cell.getElement(), row.getCell(this.columns[this.rightCol]).getElement().nextSibling);
|
|
339
|
+
cell.cellRendered();
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
this.fitDataColActualWidthCheck(column);
|
|
344
|
+
|
|
345
|
+
this.rightCol++; // Don't move this below the >= check below
|
|
346
|
+
|
|
347
|
+
this.getVisibleRows().forEach((row) => {
|
|
348
|
+
if(row.type !== "group"){
|
|
349
|
+
row.modules.vdomHoz.rightCol = this.rightCol;
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
if(this.rightCol >= (this.columns.length - 1)){
|
|
354
|
+
this.vDomPadRight = 0;
|
|
355
|
+
}else{
|
|
356
|
+
this.vDomPadRight -= column.getWidth();
|
|
357
|
+
}
|
|
358
|
+
}else{
|
|
359
|
+
working = false;
|
|
360
|
+
}
|
|
361
|
+
}else{
|
|
362
|
+
working = false;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if(changes){
|
|
367
|
+
this.tableElement.style.paddingRight = this.vDomPadRight + "px";
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
addColLeft(){
|
|
372
|
+
var changes = false,
|
|
373
|
+
working = true;
|
|
374
|
+
|
|
375
|
+
while(working){
|
|
376
|
+
let column = this.columns[this.leftCol - 1];
|
|
377
|
+
|
|
378
|
+
if(column){
|
|
379
|
+
if(column.modules.vdomHoz.rightPos >= this.vDomScrollPosLeft){
|
|
380
|
+
changes = true;
|
|
381
|
+
|
|
382
|
+
this.getVisibleRows().forEach((row) => {
|
|
383
|
+
if(row.type !== "group"){
|
|
384
|
+
var cell = row.getCell(column);
|
|
385
|
+
row.getElement().insertBefore(cell.getElement(), row.getCell(this.columns[this.leftCol]).getElement());
|
|
386
|
+
cell.cellRendered();
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
this.leftCol--; // don't move this below the <= check below
|
|
391
|
+
|
|
392
|
+
this.getVisibleRows().forEach((row) => {
|
|
393
|
+
if(row.type !== "group"){
|
|
394
|
+
row.modules.vdomHoz.leftCol = this.leftCol;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
if(this.leftCol <= 0){ // replicating logic in addColRight
|
|
399
|
+
this.vDomPadLeft = 0;
|
|
400
|
+
}else{
|
|
401
|
+
this.vDomPadLeft -= column.getWidth();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
let diff = this.fitDataColActualWidthCheck(column);
|
|
405
|
+
|
|
406
|
+
if(diff){
|
|
407
|
+
this.scrollLeft = this.elementVertical.scrollLeft = this.elementVertical.scrollLeft + diff;
|
|
408
|
+
this.vDomPadRight -= diff;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
}else{
|
|
412
|
+
working = false;
|
|
413
|
+
}
|
|
414
|
+
}else{
|
|
415
|
+
working = false;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if(changes){
|
|
420
|
+
this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
removeColRight(){
|
|
425
|
+
var changes = false,
|
|
426
|
+
working = true;
|
|
427
|
+
|
|
428
|
+
while(working){
|
|
429
|
+
let column = this.columns[this.rightCol];
|
|
430
|
+
|
|
431
|
+
if(column){
|
|
432
|
+
if(column.modules.vdomHoz.leftPos > this.vDomScrollPosRight){
|
|
433
|
+
changes = true;
|
|
434
|
+
|
|
435
|
+
this.getVisibleRows().forEach((row) => {
|
|
436
|
+
if(row.type !== "group"){
|
|
437
|
+
var cell = row.getCell(column);
|
|
438
|
+
|
|
439
|
+
try {
|
|
440
|
+
row.getElement().removeChild(cell.getElement());
|
|
441
|
+
} catch (ex) {
|
|
442
|
+
console.warn("Could not removeColRight", ex.message);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
this.vDomPadRight += column.getWidth();
|
|
448
|
+
this.rightCol --;
|
|
449
|
+
|
|
450
|
+
this.getVisibleRows().forEach((row) => {
|
|
451
|
+
if(row.type !== "group"){
|
|
452
|
+
row.modules.vdomHoz.rightCol = this.rightCol;
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
}else{
|
|
456
|
+
working = false;
|
|
457
|
+
}
|
|
458
|
+
}else{
|
|
459
|
+
working = false;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if(changes){
|
|
464
|
+
this.tableElement.style.paddingRight = this.vDomPadRight + "px";
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
removeColLeft(){
|
|
469
|
+
var changes = false,
|
|
470
|
+
working = true;
|
|
471
|
+
|
|
472
|
+
while(working){
|
|
473
|
+
let column = this.columns[this.leftCol];
|
|
474
|
+
|
|
475
|
+
if(column){
|
|
476
|
+
if(column.modules.vdomHoz.rightPos < this.vDomScrollPosLeft){
|
|
477
|
+
changes = true;
|
|
478
|
+
|
|
479
|
+
this.getVisibleRows().forEach((row) => {
|
|
480
|
+
if(row.type !== "group"){
|
|
481
|
+
var cell = row.getCell(column);
|
|
482
|
+
|
|
483
|
+
try {
|
|
484
|
+
row.getElement().removeChild(cell.getElement());
|
|
485
|
+
} catch (ex) {
|
|
486
|
+
console.warn("Could not removeColLeft", ex.message);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
this.vDomPadLeft += column.getWidth();
|
|
492
|
+
this.leftCol ++;
|
|
493
|
+
|
|
494
|
+
this.getVisibleRows().forEach((row) => {
|
|
495
|
+
if(row.type !== "group"){
|
|
496
|
+
row.modules.vdomHoz.leftCol = this.leftCol;
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
}else{
|
|
500
|
+
working = false;
|
|
501
|
+
}
|
|
502
|
+
}else{
|
|
503
|
+
working = false;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if(changes){
|
|
508
|
+
this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
fitDataColActualWidthCheck(column){
|
|
513
|
+
var newWidth, widthDiff;
|
|
514
|
+
|
|
515
|
+
if(column.modules.vdomHoz.fitDataCheck){
|
|
516
|
+
column.reinitializeWidth();
|
|
517
|
+
|
|
518
|
+
newWidth = column.getWidth();
|
|
519
|
+
widthDiff = newWidth - column.modules.vdomHoz.width;
|
|
520
|
+
|
|
521
|
+
if(widthDiff){
|
|
522
|
+
column.modules.vdomHoz.rightPos += widthDiff;
|
|
523
|
+
column.modules.vdomHoz.width = newWidth;
|
|
524
|
+
this.colPositionAdjust(this.columns.indexOf(column) + 1, this.columns.length, widthDiff);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
column.modules.vdomHoz.fitDataCheck = false;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
return widthDiff;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
initializeRow(row){
|
|
534
|
+
if(row.type !== "group"){
|
|
535
|
+
row.modules.vdomHoz = {
|
|
536
|
+
leftCol:this.leftCol,
|
|
537
|
+
rightCol:this.rightCol,
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
if(this.table.modules.frozenColumns){
|
|
541
|
+
this.table.modules.frozenColumns.leftColumns.forEach((column) => {
|
|
542
|
+
this.appendCell(row, column);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
for(let i = this.leftCol; i <= this.rightCol; i++){
|
|
547
|
+
this.appendCell(row, this.columns[i]);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if(this.table.modules.frozenColumns){
|
|
551
|
+
this.table.modules.frozenColumns.rightColumns.forEach((column) => {
|
|
552
|
+
this.appendCell(row, column);
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
appendCell(row, column){
|
|
559
|
+
if(column && column.visible){
|
|
560
|
+
let cell = row.getCell(column);
|
|
561
|
+
|
|
562
|
+
row.getElement().appendChild(cell.getElement());
|
|
563
|
+
cell.cellRendered();
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
reinitializeRow(row, force){
|
|
568
|
+
if(row.type !== "group"){
|
|
569
|
+
if(force || !row.modules.vdomHoz || row.modules.vdomHoz.leftCol !== this.leftCol || row.modules.vdomHoz.rightCol !== this.rightCol){
|
|
570
|
+
|
|
571
|
+
var rowEl = row.getElement();
|
|
572
|
+
while(rowEl.firstChild) rowEl.removeChild(rowEl.firstChild);
|
|
573
|
+
|
|
574
|
+
this.initializeRow(row);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
578
|
}
|