@syncfusion/ej2-treegrid 31.1.17 → 31.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ej2-treegrid.min.js +2 -2
- package/dist/ej2-treegrid.umd.min.js +2 -2
- package/dist/ej2-treegrid.umd.min.js.map +1 -1
- package/dist/es6/ej2-treegrid.es2015.js +13 -4
- package/dist/es6/ej2-treegrid.es2015.js.map +1 -1
- package/dist/es6/ej2-treegrid.es5.js +13 -4
- package/dist/es6/ej2-treegrid.es5.js.map +1 -1
- package/dist/global/ej2-treegrid.min.js +2 -2
- package/dist/global/ej2-treegrid.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +14 -50
- package/src/treegrid/actions/edit.js +1 -1
- package/src/treegrid/actions/rowdragdrop.js +12 -3
- package/styles/bootstrap4-lite.css +8 -0
- package/styles/bootstrap4.css +8 -0
- package/styles/treegrid/bootstrap4.css +8 -0
- package/dist/ts/index.d.ts +0 -4
- package/dist/ts/index.ts +0 -4
- package/dist/ts/treegrid/actions/batch-edit.d.ts +0 -74
- package/dist/ts/treegrid/actions/batch-edit.ts +0 -627
- package/dist/ts/treegrid/actions/clipboard.d.ts +0 -36
- package/dist/ts/treegrid/actions/clipboard.ts +0 -174
- package/dist/ts/treegrid/actions/column-chooser.d.ts +0 -37
- package/dist/ts/treegrid/actions/column-chooser.ts +0 -55
- package/dist/ts/treegrid/actions/column-menu.d.ts +0 -24
- package/dist/ts/treegrid/actions/column-menu.ts +0 -39
- package/dist/ts/treegrid/actions/command-column.d.ts +0 -24
- package/dist/ts/treegrid/actions/command-column.ts +0 -32
- package/dist/ts/treegrid/actions/context-menu.d.ts +0 -42
- package/dist/ts/treegrid/actions/context-menu.ts +0 -149
- package/dist/ts/treegrid/actions/crud-actions.d.ts +0 -66
- package/dist/ts/treegrid/actions/crud-actions.ts +0 -388
- package/dist/ts/treegrid/actions/detail-row.d.ts +0 -39
- package/dist/ts/treegrid/actions/detail-row.ts +0 -124
- package/dist/ts/treegrid/actions/edit.d.ts +0 -121
- package/dist/ts/treegrid/actions/edit.ts +0 -1083
- package/dist/ts/treegrid/actions/excel-export.d.ts +0 -67
- package/dist/ts/treegrid/actions/excel-export.ts +0 -240
- package/dist/ts/treegrid/actions/filter.d.ts +0 -57
- package/dist/ts/treegrid/actions/filter.ts +0 -231
- package/dist/ts/treegrid/actions/freeze-column.d.ts +0 -28
- package/dist/ts/treegrid/actions/freeze-column.ts +0 -119
- package/dist/ts/treegrid/actions/index.d.ts +0 -24
- package/dist/ts/treegrid/actions/index.ts +0 -24
- package/dist/ts/treegrid/actions/infinite-scroll.d.ts +0 -96
- package/dist/ts/treegrid/actions/infinite-scroll.ts +0 -320
- package/dist/ts/treegrid/actions/logger.d.ts +0 -25
- package/dist/ts/treegrid/actions/logger.ts +0 -136
- package/dist/ts/treegrid/actions/page.d.ts +0 -67
- package/dist/ts/treegrid/actions/page.ts +0 -212
- package/dist/ts/treegrid/actions/pdf-export.d.ts +0 -63
- package/dist/ts/treegrid/actions/pdf-export.ts +0 -182
- package/dist/ts/treegrid/actions/print.d.ts +0 -37
- package/dist/ts/treegrid/actions/print.ts +0 -69
- package/dist/ts/treegrid/actions/reorder.d.ts +0 -36
- package/dist/ts/treegrid/actions/reorder.ts +0 -60
- package/dist/ts/treegrid/actions/resize.d.ts +0 -36
- package/dist/ts/treegrid/actions/resize.ts +0 -54
- package/dist/ts/treegrid/actions/rowdragdrop.d.ts +0 -405
- package/dist/ts/treegrid/actions/rowdragdrop.ts +0 -1896
- package/dist/ts/treegrid/actions/selection.d.ts +0 -51
- package/dist/ts/treegrid/actions/selection.ts +0 -530
- package/dist/ts/treegrid/actions/sort.d.ts +0 -63
- package/dist/ts/treegrid/actions/sort.ts +0 -149
- package/dist/ts/treegrid/actions/summary.d.ts +0 -47
- package/dist/ts/treegrid/actions/summary.ts +0 -231
- package/dist/ts/treegrid/actions/toolbar.d.ts +0 -52
- package/dist/ts/treegrid/actions/toolbar.ts +0 -154
- package/dist/ts/treegrid/actions/virtual-scroll.d.ts +0 -90
- package/dist/ts/treegrid/actions/virtual-scroll.ts +0 -306
- package/dist/ts/treegrid/base/constant.d.ts +0 -158
- package/dist/ts/treegrid/base/constant.ts +0 -158
- package/dist/ts/treegrid/base/data.d.ts +0 -90
- package/dist/ts/treegrid/base/data.ts +0 -904
- package/dist/ts/treegrid/base/index.d.ts +0 -11
- package/dist/ts/treegrid/base/index.ts +0 -11
- package/dist/ts/treegrid/base/interface.d.ts +0 -186
- package/dist/ts/treegrid/base/interface.ts +0 -191
- package/dist/ts/treegrid/base/treegrid-model.d.ts +0 -1100
- package/dist/ts/treegrid/base/treegrid.d.ts +0 -2422
- package/dist/ts/treegrid/base/treegrid.ts +0 -5962
- package/dist/ts/treegrid/enum.d.ts +0 -152
- package/dist/ts/treegrid/enum.ts +0 -217
- package/dist/ts/treegrid/index.d.ts +0 -9
- package/dist/ts/treegrid/index.ts +0 -9
- package/dist/ts/treegrid/models/column-chooser-settings-model.d.ts +0 -62
- package/dist/ts/treegrid/models/column-chooser-settings.d.ts +0 -53
- package/dist/ts/treegrid/models/column-chooser-settings.ts +0 -67
- package/dist/ts/treegrid/models/column-model.d.ts +0 -30
- package/dist/ts/treegrid/models/column.d.ts +0 -697
- package/dist/ts/treegrid/models/column.ts +0 -800
- package/dist/ts/treegrid/models/edit-settings-model.d.ts +0 -100
- package/dist/ts/treegrid/models/edit-settings.d.ts +0 -89
- package/dist/ts/treegrid/models/edit-settings.ts +0 -111
- package/dist/ts/treegrid/models/filter-settings-model.d.ts +0 -216
- package/dist/ts/treegrid/models/filter-settings.d.ts +0 -195
- package/dist/ts/treegrid/models/filter-settings.ts +0 -237
- package/dist/ts/treegrid/models/index.d.ts +0 -24
- package/dist/ts/treegrid/models/index.ts +0 -24
- package/dist/ts/treegrid/models/infinite-scroll-settings-model.d.ts +0 -29
- package/dist/ts/treegrid/models/infinite-scroll-settings.d.ts +0 -25
- package/dist/ts/treegrid/models/infinite-scroll-settings.ts +0 -31
- package/dist/ts/treegrid/models/loading-indicator-model.d.ts +0 -21
- package/dist/ts/treegrid/models/loading-indicator.d.ts +0 -19
- package/dist/ts/treegrid/models/loading-indicator.ts +0 -21
- package/dist/ts/treegrid/models/page-settings-model.d.ts +0 -66
- package/dist/ts/treegrid/models/page-settings.d.ts +0 -57
- package/dist/ts/treegrid/models/page-settings.ts +0 -73
- package/dist/ts/treegrid/models/rowdrop-settings-model.d.ts +0 -15
- package/dist/ts/treegrid/models/rowdrop-settings.d.ts +0 -34
- package/dist/ts/treegrid/models/rowdrop-settings.ts +0 -37
- package/dist/ts/treegrid/models/search-settings-model.d.ts +0 -79
- package/dist/ts/treegrid/models/search-settings.d.ts +0 -73
- package/dist/ts/treegrid/models/search-settings.ts +0 -83
- package/dist/ts/treegrid/models/selection-settings-model.d.ts +0 -76
- package/dist/ts/treegrid/models/selection-settings.d.ts +0 -68
- package/dist/ts/treegrid/models/selection-settings.ts +0 -82
- package/dist/ts/treegrid/models/sort-settings-model.d.ts +0 -49
- package/dist/ts/treegrid/models/sort-settings.d.ts +0 -43
- package/dist/ts/treegrid/models/sort-settings.ts +0 -51
- package/dist/ts/treegrid/models/summary-model.d.ts +0 -93
- package/dist/ts/treegrid/models/summary.d.ts +0 -126
- package/dist/ts/treegrid/models/summary.ts +0 -170
- package/dist/ts/treegrid/models/textwrap-settings-model.d.ts +0 -21
- package/dist/ts/treegrid/models/textwrap-settings.d.ts +0 -19
- package/dist/ts/treegrid/models/textwrap-settings.ts +0 -21
- package/dist/ts/treegrid/renderer/index.d.ts +0 -5
- package/dist/ts/treegrid/renderer/index.ts +0 -5
- package/dist/ts/treegrid/renderer/render.d.ts +0 -41
- package/dist/ts/treegrid/renderer/render.ts +0 -379
- package/dist/ts/treegrid/renderer/virtual-row-model-generator.d.ts +0 -16
- package/dist/ts/treegrid/renderer/virtual-row-model-generator.ts +0 -90
- package/dist/ts/treegrid/renderer/virtual-tree-content-render.d.ts +0 -353
- package/dist/ts/treegrid/renderer/virtual-tree-content-render.ts +0 -1125
- package/dist/ts/treegrid/utils.d.ts +0 -70
- package/dist/ts/treegrid/utils.ts +0 -217
|
@@ -1,1125 +0,0 @@
|
|
|
1
|
-
import { Cell, CellType, Column, getVisiblePage, ICell, NotifyArgs, Row, SentinelInfo, SentinelType } from '@syncfusion/ej2-grids';
|
|
2
|
-
import { Offsets, VirtualInfo, ServiceLocator, IGrid, IModelGenerator } from '@syncfusion/ej2-grids';
|
|
3
|
-
import { VirtualContentRenderer } from '@syncfusion/ej2-grids';
|
|
4
|
-
import { RowPosition } from '../enum';
|
|
5
|
-
import * as literals from '../base/constant';
|
|
6
|
-
import { InterSectionObserver, RowSelectEventArgs } from '@syncfusion/ej2-grids';
|
|
7
|
-
import { TreeVirtualRowModelGenerator } from '../renderer/virtual-row-model-generator';
|
|
8
|
-
import * as events from '../base/constant';
|
|
9
|
-
import { isNullOrUndefined, EventHandler, getValue, setValue, Browser, KeyboardEventArgs, debounce } from '@syncfusion/ej2-base';
|
|
10
|
-
import { DataManager, Query } from '@syncfusion/ej2-data';
|
|
11
|
-
import { isCountRequired, isRemoteData } from '../utils';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* VirtualTreeContentRenderer
|
|
15
|
-
*
|
|
16
|
-
* @hidden
|
|
17
|
-
*/
|
|
18
|
-
export class VirtualTreeContentRenderer extends VirtualContentRenderer {
|
|
19
|
-
public getModelGenerator(): IModelGenerator<Column> {
|
|
20
|
-
return new TreeVirtualRowModelGenerator(this.parent);
|
|
21
|
-
}
|
|
22
|
-
constructor(parent: IGrid, locator?: ServiceLocator) {
|
|
23
|
-
super(parent, locator);
|
|
24
|
-
this.addEventListener();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private isExpandCollapse: boolean = false;
|
|
28
|
-
private observers: TreeInterSectionObserver;
|
|
29
|
-
private translateY: number = 0;
|
|
30
|
-
private maxiPage: number = 0;
|
|
31
|
-
private rowPosition: RowPosition;
|
|
32
|
-
private addRowIndex: number;
|
|
33
|
-
private dataRowIndex: number;
|
|
34
|
-
private recordAdded: boolean = false;
|
|
35
|
-
/** @hidden */
|
|
36
|
-
public startIndex: number = -1;
|
|
37
|
-
private endIndex: number = -1;
|
|
38
|
-
private totalRecords: number;
|
|
39
|
-
private contents: HTMLElement;
|
|
40
|
-
private fn: Function;
|
|
41
|
-
private preTranslate: number = 0;
|
|
42
|
-
private isRemoteExpand: boolean = false;
|
|
43
|
-
private previousInfo: VirtualInfo;
|
|
44
|
-
/** @hidden */
|
|
45
|
-
public isDataSourceChanged: boolean = false;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Retrieves the row element for a given row index.
|
|
49
|
-
*
|
|
50
|
-
* @param {number} index - The index of the row to retrieve.
|
|
51
|
-
* @returns {Element} The row element at the specified index.
|
|
52
|
-
*/
|
|
53
|
-
public getRowByIndex(index: number): Element {
|
|
54
|
-
if (this.parent.enableVirtualization && this.parent.isFrozenGrid()) {
|
|
55
|
-
return this.getRowCollection(index, true) as Element;
|
|
56
|
-
}
|
|
57
|
-
const dataRows: Element[] = this.parent.getDataRows();
|
|
58
|
-
const targetRow: Element = dataRows.find((e: HTMLElement) => parseInt(e.getAttribute('aria-rowindex'), 10) - 1 === index);
|
|
59
|
-
if (!targetRow && this.parent.isEdit && this.parent.editSettings.mode === 'Batch') {
|
|
60
|
-
return index != null ? this.parent.getRows()[parseInt(index.toString(), 10)] : undefined;
|
|
61
|
-
}
|
|
62
|
-
return targetRow;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Retrieves the frozen right virtual row element by its index.
|
|
67
|
-
*
|
|
68
|
-
* @param {number} index - The index of the row to be retrieved.
|
|
69
|
-
* @returns {Element} The DOM element representing the frozen right virtual row.
|
|
70
|
-
*/
|
|
71
|
-
public getFrozenRightVirtualRowByIndex(index: number): Element {
|
|
72
|
-
return this.getRowCollection(index, false, false, true) as Element;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Retrieves the row or record from the virtual tree grid based on the provided index.
|
|
77
|
-
* Considers conditions such as frozen rows and pagination for accurate retrieval.
|
|
78
|
-
*
|
|
79
|
-
* @param {number} index - The index of the desired row or record.
|
|
80
|
-
* @param {boolean} isMovable - Specifies if the content is movable.
|
|
81
|
-
* @param {boolean} [isRowObject] - Optional. Determines if the return value should be a row object.
|
|
82
|
-
* @param {boolean} [isFrozenRight] - Optional. Used for determining frozen right rows.
|
|
83
|
-
* @returns {Element | Object} - The HTML element or row object.
|
|
84
|
-
*/
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
86
|
-
public getRowCollection(index: number, isMovable: boolean, isRowObject?: boolean, isFrozenRight?: boolean): Element | Object {
|
|
87
|
-
const startIdx: number = parseInt(this.parent.getRows()[0].getAttribute(literals.ariaRowIndex), 10) - 1;
|
|
88
|
-
const rowCollection: Element[] = this.parent.getDataRows();
|
|
89
|
-
const collection: Element[] | Object[] = isRowObject ? this.parent.getCurrentViewRecords() : rowCollection;
|
|
90
|
-
let selectedRow: Element | Object = collection[index - startIdx];
|
|
91
|
-
if (this.parent.frozenRows && this.parent.pageSettings.currentPage > 1) {
|
|
92
|
-
if (!isRowObject) {
|
|
93
|
-
selectedRow = index <= this.parent.frozenRows ? rowCollection[parseInt(index.toString(), 10)]
|
|
94
|
-
: rowCollection[(index - startIdx) + this.parent.frozenRows];
|
|
95
|
-
} else {
|
|
96
|
-
selectedRow = index <= this.parent.frozenRows ?
|
|
97
|
-
this.parent.getRowsObject()[parseInt(index.toString(), 10)].data : selectedRow;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (selectedRow == null && index != null && this.parent.editSettings.mode === 'Batch' && this.parent.isEdit && isMovable) {
|
|
101
|
-
selectedRow = rowCollection[parseInt(index.toString(), 10)];
|
|
102
|
-
}
|
|
103
|
-
return selectedRow;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* @hidden
|
|
108
|
-
* @returns {void}
|
|
109
|
-
*/
|
|
110
|
-
public addEventListener(): void {
|
|
111
|
-
this.parent.on(events.virtualActionArgs, this.virtualOtherAction, this);
|
|
112
|
-
this.parent.on(events.indexModifier, this.indexModifier, this);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Handles virtual scrolling actions based on the provided arguments.
|
|
117
|
-
*
|
|
118
|
-
* @param {Object} args - The argument object.
|
|
119
|
-
* @param {boolean} args.setTop - Determines if the virtual scroll position should reset to top.
|
|
120
|
-
* @param {boolean} args.isExpandCollapse - Determines if the action is part of an expand/collapse operation.
|
|
121
|
-
* @returns {void}
|
|
122
|
-
*/
|
|
123
|
-
private virtualOtherAction(args: {setTop: boolean, isExpandCollapse: boolean}): void {
|
|
124
|
-
if (args.setTop) {
|
|
125
|
-
this.translateY = 0;
|
|
126
|
-
this.startIndex = 0;
|
|
127
|
-
this.endIndex = this.parent.pageSettings.pageSize - 1;
|
|
128
|
-
} else if (args.isExpandCollapse) {
|
|
129
|
-
this.isExpandCollapse = true;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Modifies the index based on various conditions such as record addition, deletion, or data source changes.
|
|
135
|
-
*
|
|
136
|
-
* @private
|
|
137
|
-
* @param {Object} args - Contains parameters for the current operation.
|
|
138
|
-
* @param {number} args.startIndex - The starting index for the modification.
|
|
139
|
-
* @param {number} args.endIndex - The ending index for the modification.
|
|
140
|
-
* @param {number} args.count - The number of items affected in the operation.
|
|
141
|
-
* @param {string} args.requestType - The type of request, such as 'insert', 'delete', or 'update'.
|
|
142
|
-
* @returns {void}
|
|
143
|
-
*/
|
|
144
|
-
private indexModifier(args: {startIndex: number, endIndex: number, count: number, requestType: string}) : void {
|
|
145
|
-
const content: HTMLElement = this.parent.getContent().querySelector('.e-content');
|
|
146
|
-
const pageSize: number = this.parent.pageSettings.pageSize;
|
|
147
|
-
if ((this.recordAdded || args.requestType === 'delete' && this.endIndex > args.count - this.parent.pageSettings.pageSize) && this.startIndex > -1 && this.endIndex > -1) {
|
|
148
|
-
if (this.endIndex > args.count - pageSize) {
|
|
149
|
-
const nextSetResIndex: number = ~~(content.scrollTop / this.parent.getRowHeight());
|
|
150
|
-
let lastIndex: number = nextSetResIndex + this.parent.getRows().length;
|
|
151
|
-
if (lastIndex > args.count) {
|
|
152
|
-
lastIndex = nextSetResIndex +
|
|
153
|
-
(args.count - nextSetResIndex);
|
|
154
|
-
}
|
|
155
|
-
this.startIndex = lastIndex - this.parent.getRows().length;
|
|
156
|
-
this.endIndex = lastIndex;
|
|
157
|
-
}
|
|
158
|
-
else if (this.parent.root.editSettings.newRowPosition !== 'Top' && this.parent.root.editModule.selectedIndex !== -1 || this.parent.root.editModule.selectedIndex !== -1) {
|
|
159
|
-
this.startIndex += 1;
|
|
160
|
-
this.endIndex += 1;
|
|
161
|
-
}
|
|
162
|
-
this.recordAdded = false;
|
|
163
|
-
}
|
|
164
|
-
if (this.isDataSourceChanged) {
|
|
165
|
-
this.startIndex = 0;
|
|
166
|
-
this.endIndex = pageSize - 1;
|
|
167
|
-
}
|
|
168
|
-
if ((this.endIndex - this.startIndex !== pageSize) &&
|
|
169
|
-
(this.totalRecords > pageSize)
|
|
170
|
-
&& (this.endIndex === this.totalRecords)){
|
|
171
|
-
args.startIndex = this.endIndex - pageSize;
|
|
172
|
-
args.endIndex = this.endIndex;
|
|
173
|
-
}
|
|
174
|
-
else{
|
|
175
|
-
args.startIndex = this.startIndex;
|
|
176
|
-
args.endIndex = this.endIndex;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Handles the addition or removal of event listeners for virtual scrolling in a TreeGrid.
|
|
182
|
-
*
|
|
183
|
-
* @param {string} action - The action to perform, either 'on' or 'off'.
|
|
184
|
-
* @returns {void}
|
|
185
|
-
*/
|
|
186
|
-
public eventListener(action: string): void {
|
|
187
|
-
if (!(this.parent.dataSource instanceof DataManager && (this.parent.dataSource as DataManager).dataSource.url !== undefined
|
|
188
|
-
&& (this.parent.dataSource as DataManager).dataSource.offline && (this.parent.dataSource as DataManager).dataSource.url !== '') || !isCountRequired(this.parent)) {
|
|
189
|
-
this.parent[`${action}`]('data-ready', this.onDataReady, this);
|
|
190
|
-
this.parent[`${action}`]('refresh-virtual-block', this.refreshContentRows, this);
|
|
191
|
-
this.fn = () => {
|
|
192
|
-
this.observers.observes((scrollArgs: ScrollArg) => this.scrollListeners(scrollArgs), this.onEnteredAction(), this.parent);
|
|
193
|
-
const gObj: IGrid = this.parent;
|
|
194
|
-
if (gObj.root.enablePersistence && gObj.root.scrollPosition) {
|
|
195
|
-
this.content.scrollTop = gObj.root.scrollPosition.top;
|
|
196
|
-
if (gObj.root.enableColumnVirtualization) {
|
|
197
|
-
this.content.scrollLeft = gObj.root.scrollPosition.left;
|
|
198
|
-
}
|
|
199
|
-
const scrollValues: any = {
|
|
200
|
-
direction: 'down', sentinel: this.observer.sentinelInfo.down,
|
|
201
|
-
offset: gObj.root.scrollPosition, focusElement: gObj.element
|
|
202
|
-
};
|
|
203
|
-
this.scrollListeners(scrollValues);
|
|
204
|
-
}
|
|
205
|
-
this.parent.off('content-ready', this.fn);
|
|
206
|
-
};
|
|
207
|
-
this.parent.addEventListener('dataBound', this.dataBoundEvent.bind(this));
|
|
208
|
-
this.parent.addEventListener('rowSelected', this.rowSelectedEvent.bind(this));
|
|
209
|
-
this.parent[`${action}`]('select-virtual-Row', this.toSelectVirtualRow, this);
|
|
210
|
-
this.parent.on('content-ready', this.fn, this);
|
|
211
|
-
this.parent.addEventListener(events.actionBegin, this.handleActionBegin.bind(this));
|
|
212
|
-
this.parent.addEventListener(events.actionComplete, this.onActionComplete.bind(this));
|
|
213
|
-
this.parent[`${action}`]('virtual-scroll-edit-action-begin', this.beginEdit, this);
|
|
214
|
-
this.parent[`${action}`]('virtual-scroll-add-action-begin', this.beginAdd, this);
|
|
215
|
-
this.parent[`${action}`]('virtual-scroll-edit-success', this.virtualEditSuccess, this);
|
|
216
|
-
this.parent[`${action}`]('edit-reset', this.resetIseditValue, this);
|
|
217
|
-
this.parent[`${action}`]('get-virtual-data', this.getData, this);
|
|
218
|
-
this.parent[`${action}`]('virtual-scroll-edit-cancel', this.cancelEdit, this);
|
|
219
|
-
this.parent[`${action}`]('select-row-on-context-open', this.toSelectRowOnContextOpen, this);
|
|
220
|
-
this.parent[`${action}`]('refresh-virtual-editform-cells', this.refreshCell, this);
|
|
221
|
-
this.parent[`${action}`]('virtaul-cell-focus', this.cellFocus, this);
|
|
222
|
-
this.parent[`${action}`]('virtual-scroll-edit', this.restoreEditState, this);
|
|
223
|
-
this.parent[`${action}`]('set-virtual-page-query', this.SetVirtualPageQury, this);
|
|
224
|
-
} else {
|
|
225
|
-
super.eventListener('on');
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Handles cell focus transitions in a virtualized tree grid component
|
|
231
|
-
* when a keyboard event is triggered.
|
|
232
|
-
*
|
|
233
|
-
* @param {KeyboardEventArgs} e - The keyboard event arguments that contain
|
|
234
|
-
* information about the key action.
|
|
235
|
-
* @returns {void}
|
|
236
|
-
*/
|
|
237
|
-
private cellFocus(e: KeyboardEventArgs): void {
|
|
238
|
-
const virtualCellFocus: string = 'virtualCellFocus';
|
|
239
|
-
super[`${virtualCellFocus}`](e);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Handles the data ready event for the virtual tree grid content renderer.
|
|
244
|
-
*
|
|
245
|
-
* @param {NotifyArgs} [e] - The notification arguments that contain information about the data.
|
|
246
|
-
* @returns {void}
|
|
247
|
-
*/
|
|
248
|
-
protected onDataReady(e?: NotifyArgs): void {
|
|
249
|
-
super.onDataReady(e);
|
|
250
|
-
if (!(this.parent.dataSource instanceof DataManager && (this.parent.dataSource as DataManager).dataSource.url !== undefined
|
|
251
|
-
&& (this.parent.dataSource as DataManager).dataSource.offline && (this.parent.dataSource as DataManager).dataSource.url !== '') || !isCountRequired(this.parent)) {
|
|
252
|
-
if (!isNullOrUndefined(e.count)) {
|
|
253
|
-
this.totalRecords = e.count;
|
|
254
|
-
// To overcome the white space issue in last page when records collapsed
|
|
255
|
-
if (this.parent.isFrozenGrid() && e.count < Object.keys(this.parent.dataSource).length) {
|
|
256
|
-
const width: string = this.parent.enableColumnVirtualization ?
|
|
257
|
-
this.getColumnOffset(this.parent.columns.length - 1) + 'px' : '100%';
|
|
258
|
-
const height: number = (this.parent.getRowHeight() * e.count) -
|
|
259
|
-
(this.parent.getRowHeight() * this.parent.pageSettings.pageSize);
|
|
260
|
-
getValue('virtualEle', this).setVirtualHeight(height, width);
|
|
261
|
-
}
|
|
262
|
-
if (!this.parent.enableColumnVirtualization && !this.parent.isFrozenGrid()) {
|
|
263
|
-
getValue('virtualEle', this).setVirtualHeight(this.parent.getRowHeight() * e.count, '100%');
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
if ((!isNullOrUndefined(e.requestType) && e.requestType.toString() === 'collapseAll') || (this.isDataSourceChanged && (this.startIndex === -1 || this.startIndex === 0 && this['preStartIndex'] === 0))) {
|
|
267
|
-
this.contents.scrollTop = 0;
|
|
268
|
-
this.isDataSourceChanged = false;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Renders the table for the virtual tree content. It sets up a new `TreeInterSectionObserver`
|
|
275
|
-
* based on certain conditions regarding the data source and counting requirements.
|
|
276
|
-
*
|
|
277
|
-
* @returns {void}
|
|
278
|
-
*/
|
|
279
|
-
public renderTable() : void {
|
|
280
|
-
super.renderTable();
|
|
281
|
-
if (!(this.parent.dataSource instanceof DataManager && (this.parent.dataSource as DataManager).dataSource.url !== undefined
|
|
282
|
-
&& (this.parent.dataSource as DataManager).dataSource.offline && (this.parent.dataSource as DataManager).dataSource.url !== '') || !isCountRequired(this.parent)) {
|
|
283
|
-
getValue('observer', this).options.debounceEvent = false;
|
|
284
|
-
this.observers = new TreeInterSectionObserver(getValue('observer', this).element,
|
|
285
|
-
getValue('observer', this).options);
|
|
286
|
-
this.contents = this.getPanel().firstChild as HTMLElement;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Calculates the translateY value for a virtual tree grid based on the scroll top, container height,
|
|
292
|
-
* and additional virtual scrolling information. This method specifically handles logic for remote
|
|
293
|
-
* data sources and ensures smooth scrolling with respect to expansion states.
|
|
294
|
-
*
|
|
295
|
-
* @param {number} sTop - The scroll top position.
|
|
296
|
-
* @param {number} cHeight - The height of the container.
|
|
297
|
-
* @param {VirtualInfo} [info] - Optional virtual scrolling information.
|
|
298
|
-
* @param {boolean} [isOnenter] - Flag indicating if the scroll event is on enter.
|
|
299
|
-
* @returns {number} The calculated translateY value.
|
|
300
|
-
*/
|
|
301
|
-
protected getTranslateY(sTop: number, cHeight: number, info?: VirtualInfo, isOnenter?: boolean): number {
|
|
302
|
-
if ((this.parent.dataSource instanceof DataManager && (this.parent.dataSource as DataManager).dataSource.url !== undefined
|
|
303
|
-
&& !(this.parent.dataSource as DataManager).dataSource.offline && (this.parent.dataSource as DataManager).dataSource.url !== '') || isCountRequired(this.parent)) {
|
|
304
|
-
if (this.isRemoteExpand) {
|
|
305
|
-
this.isRemoteExpand = false;
|
|
306
|
-
return this.preTranslate;
|
|
307
|
-
}
|
|
308
|
-
this.preTranslate = super.getTranslateY(sTop, cHeight, info, isOnenter);
|
|
309
|
-
}
|
|
310
|
-
return super.getTranslateY(sTop, cHeight, info, isOnenter);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Handles the dataBound event to calculate and set the initial row top position for the grid.
|
|
315
|
-
*
|
|
316
|
-
* @returns {void}
|
|
317
|
-
*/
|
|
318
|
-
private dataBoundEvent(): void {
|
|
319
|
-
const dataBoundEve: string = 'dataBound'; const initialRowTop: string = 'initialRowTop';
|
|
320
|
-
if (!isNullOrUndefined(this.parent.getRows()) && this.parent.getRows().length && !isNullOrUndefined(this.parent.getRowByIndex(0)) && !this[`${initialRowTop}`]) {
|
|
321
|
-
const rowTop: number = this.parent.getRowByIndex(0).getBoundingClientRect().top;
|
|
322
|
-
const gridTop: number = this.parent.element.getBoundingClientRect().top;
|
|
323
|
-
if (rowTop > 0){
|
|
324
|
-
this[`${initialRowTop}`] = this.parent.getRowByIndex(0).getBoundingClientRect().top - gridTop;
|
|
325
|
-
} else if (this.parent.selectedRowIndex === -1) {
|
|
326
|
-
this[`${initialRowTop}`] = this.content.getBoundingClientRect().top -
|
|
327
|
-
this.parent.getRowByIndex(0).getBoundingClientRect().height;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
super[`${dataBoundEve}`]();
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Handles the row selection event for virtual tree grid rows.
|
|
335
|
-
* It invokes the base class's rowSelected method and notifies
|
|
336
|
-
* the parent component about a virtual transformation change.
|
|
337
|
-
*
|
|
338
|
-
* @param {RowSelectEventArgs} args - The arguments related to the row selection event.
|
|
339
|
-
* @returns {void} This method does not return a value.
|
|
340
|
-
*/
|
|
341
|
-
private rowSelectedEvent(args: RowSelectEventArgs): void {
|
|
342
|
-
const rowSelected: string = 'rowSelected';
|
|
343
|
-
super[`${rowSelected}`](args);
|
|
344
|
-
this.parent.notify('virtualTransform', { requestType: 'transformChange'});
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Handles virtual row selection in TreeGrid.
|
|
349
|
-
*
|
|
350
|
-
* @param {Object} args - The argument object containing the selected index.
|
|
351
|
-
* @param {number} args.selectedIndex - The index of the row to be selected.
|
|
352
|
-
*
|
|
353
|
-
* @returns {void}
|
|
354
|
-
*/
|
|
355
|
-
private toSelectVirtualRow(args: { selectedIndex: number }): void {
|
|
356
|
-
if (this.parent.isEdit) { return; }
|
|
357
|
-
const selectVirtualRow: string = 'selectVirtualRow';
|
|
358
|
-
const containerRect: string = 'containerRect';
|
|
359
|
-
if (isNullOrUndefined(this.observer[`${containerRect}`])) {
|
|
360
|
-
this.observer[`${containerRect}`] = this.observers[`${containerRect}`];
|
|
361
|
-
}
|
|
362
|
-
const treeGridParent: any = this.parent.clipboardModule['treeGridParent'];
|
|
363
|
-
if (isNullOrUndefined(treeGridParent.editModule) ||
|
|
364
|
-
isNullOrUndefined(treeGridParent.editModule['addRowIndex']) || args.selectedIndex !== 0) {
|
|
365
|
-
if (!isNullOrUndefined(treeGridParent.grid.sortModule) && treeGridParent.grid.sortModule['sortedColumns'].length > 0) {
|
|
366
|
-
const sortedData : any = treeGridParent.dataModule['sortedData'];
|
|
367
|
-
if (!isNullOrUndefined(sortedData) && sortedData.length > 0) {
|
|
368
|
-
const targetIndex : number = sortedData.findIndex((record: { index: number }) => record.index === args.selectedIndex);
|
|
369
|
-
args.selectedIndex = targetIndex;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
super[`${selectVirtualRow}`](args);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Refreshes the cells for the given row object by regenerating them.
|
|
378
|
-
*
|
|
379
|
-
* @param {Row<Column>} rowObj - The row object for which the cells need to be refreshed.
|
|
380
|
-
* @returns {void} This method does not return any value.
|
|
381
|
-
*/
|
|
382
|
-
private refreshCell(rowObj: Row<Column>): void {
|
|
383
|
-
rowObj.cells = this.generateCells();
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Generates an array of cells for each column in the parent.
|
|
388
|
-
*
|
|
389
|
-
* @returns {Cell<Column>[]} An array of cells for the corresponding columns.
|
|
390
|
-
*/
|
|
391
|
-
public generateCells(): Cell<Column>[] {
|
|
392
|
-
const cells: Cell<Column>[] = [];
|
|
393
|
-
for (let i: number = 0; i < this.parent.columns.length; i++) {
|
|
394
|
-
cells.push(this.generateCell(this.parent.columns[parseInt(i.toString(), 10)] as Column));
|
|
395
|
-
}
|
|
396
|
-
return cells;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Generates a cell object with provided column and row configurations.
|
|
401
|
-
*
|
|
402
|
-
* @param {Column} col - The Column object which holds the column configuration.
|
|
403
|
-
* @param {string} [rowId] - An optional string that represents the row ID.
|
|
404
|
-
* @param {CellType} [cellType] - An optional CellType enum to specify the type of the cell.
|
|
405
|
-
* @param {number} [colSpan] - An optional number to specify the column span of the cell.
|
|
406
|
-
* @param {number} [oIndex] - An optional number for the order index of the cell.
|
|
407
|
-
* @param {Object} [foreignKeyData] - An optional object for foreign key data associated with the column.
|
|
408
|
-
*
|
|
409
|
-
* @returns {Cell<Column>} Returns a newly created Cell object of type Column.
|
|
410
|
-
*/
|
|
411
|
-
public generateCell(
|
|
412
|
-
col: Column, rowId?: string, cellType?: CellType, colSpan?: number,
|
|
413
|
-
oIndex?: number, foreignKeyData?: Object): Cell<Column> {
|
|
414
|
-
const opt: ICell<Column> = {
|
|
415
|
-
'visible': col.visible,
|
|
416
|
-
'isDataCell': !isNullOrUndefined(col.field || col.template),
|
|
417
|
-
'isTemplate': !isNullOrUndefined(col.template),
|
|
418
|
-
'rowID': rowId,
|
|
419
|
-
'column': col,
|
|
420
|
-
'cellType': !isNullOrUndefined(cellType) ? cellType : CellType.Data,
|
|
421
|
-
'colSpan': colSpan,
|
|
422
|
-
'commands': col.commands,
|
|
423
|
-
'isForeignKey': col.isForeignColumn && col.isForeignColumn(),
|
|
424
|
-
'foreignKeyData': col.isForeignColumn && col.isForeignColumn() && getValue(col.field, foreignKeyData)
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
if (opt.isDataCell || opt.column.type === 'checkbox' || opt.commands) {
|
|
428
|
-
opt.index = oIndex;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
return new Cell<Column>(<{ [x: string]: Object }>opt);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Begins the edit operation for a specified row in the grid.
|
|
436
|
-
* Updates the `editedRowIndex` and assigns row data to the event data.
|
|
437
|
-
*
|
|
438
|
-
* @param {{ data: Object, index: number }} e - An object containing the row data and index.
|
|
439
|
-
* @param {Object} e.data - The data of the row to be edited.
|
|
440
|
-
* @param {number} e.index - The index of the row to be edited.
|
|
441
|
-
* @returns {void}
|
|
442
|
-
*/
|
|
443
|
-
private beginEdit(e: { data: Object, index: number }): void {
|
|
444
|
-
this['editedRowIndex'] = e.index;
|
|
445
|
-
const selector: string = '.e-row[aria-rowindex="' + (e.index + 1) + '"]';
|
|
446
|
-
const index: number = (this.parent.getContent().querySelector(selector) as HTMLTableRowElement).rowIndex;
|
|
447
|
-
const rowData: Object = this.parent.getCurrentViewRecords()[parseInt(index.toString(), 10)];
|
|
448
|
-
e.data = rowData;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Begins the process of adding a new row in the tree grid.
|
|
453
|
-
*
|
|
454
|
-
* @param {Object} args - The arguments for adding a new row.
|
|
455
|
-
* @param {boolean} args.startEdit - A flag indicating whether to start editing.
|
|
456
|
-
* @returns {void}
|
|
457
|
-
*/
|
|
458
|
-
private beginAdd(args: { startEdit: boolean }): void {
|
|
459
|
-
const addAction: string = 'addActionBegin'; const isAdd: string = 'isAdd';
|
|
460
|
-
const addArgs: { newRowPosition: RowPosition, addRowIndex: number, dataRowIndex: number }
|
|
461
|
-
= { newRowPosition: this.rowPosition, addRowIndex: this.addRowIndex, dataRowIndex: this.dataRowIndex };
|
|
462
|
-
this.parent.notify('get-row-position', addArgs);
|
|
463
|
-
this.rowPosition = addArgs.newRowPosition;
|
|
464
|
-
this.addRowIndex = addArgs.addRowIndex;
|
|
465
|
-
this.dataRowIndex = addArgs.dataRowIndex;
|
|
466
|
-
const rows: HTMLTableRowElement[] = <HTMLTableRowElement[]>this.parent.getRows();
|
|
467
|
-
const firstAriaIndex: number = rows.length ? +rows[0].getAttribute('aria-rowindex') - 1 : 0;
|
|
468
|
-
const lastAriaIndex: number = rows.length ? +rows[rows.length - 1].getAttribute('aria-rowindex') - 1 : 0;
|
|
469
|
-
const withInRange: boolean = this.parent.selectedRowIndex >= firstAriaIndex && this.parent.selectedRowIndex <= lastAriaIndex;
|
|
470
|
-
if (!(this.rowPosition === 'Top' || this.rowPosition === 'Bottom')) {
|
|
471
|
-
this[`${isAdd}`] = true;
|
|
472
|
-
}
|
|
473
|
-
if (this.rowPosition === 'Top' || this.rowPosition === 'Bottom' ||
|
|
474
|
-
((!this.addRowIndex || this.addRowIndex === -1) && (this.parent.selectedRowIndex === -1 || !withInRange))) {
|
|
475
|
-
super[`${addAction}`](args);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* Restores the edit state of the tree grid content. This method calls the
|
|
481
|
-
* base class method to handle the restoration logic.
|
|
482
|
-
*
|
|
483
|
-
* @returns {void} This method does not return any value.
|
|
484
|
-
*/
|
|
485
|
-
private restoreEditState(): void {
|
|
486
|
-
const restoreEdit: string = 'restoreEdit';
|
|
487
|
-
super[`${restoreEdit}`]();
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
private SetVirtualPageQury(args: { query: Query, skipPage: boolean }): void {
|
|
491
|
-
let visiblePage: number[] = [];
|
|
492
|
-
if (this.prevInfo && this.prevInfo.blockIndexes) {
|
|
493
|
-
visiblePage = getVisiblePage(this.prevInfo.blockIndexes);
|
|
494
|
-
}
|
|
495
|
-
if ((this.requestType === 'refresh') && visiblePage.length) {
|
|
496
|
-
args.query.skip(this.parent.pageSettings.pageSize * (visiblePage[0] - 1));
|
|
497
|
-
args.query.take(this.parent.pageSettings.pageSize * visiblePage.length);
|
|
498
|
-
args.skipPage = true;
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Resets the edit state if certain conditions are met.
|
|
505
|
-
*
|
|
506
|
-
* @returns {void}
|
|
507
|
-
*/
|
|
508
|
-
private resetIseditValue(): void {
|
|
509
|
-
const resetIsEdit: string = 'resetIsedit'; const isAdd: string = 'isAdd';
|
|
510
|
-
this.parent.notify('reset-edit-props', {});
|
|
511
|
-
if ((this.rowPosition === 'Top' || this.rowPosition === 'Bottom') && this[`${isAdd}`]) {
|
|
512
|
-
super[`${resetIsEdit}`]();
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Handles the successful editing operation when virtual scrolling is enabled.
|
|
518
|
-
* Checks if a row has been added to the tree grid and sets the `recordAdded` flag accordingly.
|
|
519
|
-
*
|
|
520
|
-
* @returns {void}
|
|
521
|
-
*/
|
|
522
|
-
private virtualEditSuccess(): void {
|
|
523
|
-
const isAdd: string = 'isAdd';
|
|
524
|
-
const content: HTMLElement = this.parent.getContent().querySelector('.e-content');
|
|
525
|
-
if (this[`${isAdd}`] && content.querySelector('.e-addedrow')) {
|
|
526
|
-
this.recordAdded = true;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* Cancels the edit operation for the provided data.
|
|
532
|
-
*
|
|
533
|
-
* @param {Object} args - The arguments containing the data to cancel edit for.
|
|
534
|
-
* @param {Object} args.data - The specific data object for which the edit operation needs to be canceled.
|
|
535
|
-
* @returns {void}
|
|
536
|
-
*/
|
|
537
|
-
private cancelEdit(args: { data: Object }): void {
|
|
538
|
-
const editCancel: string = 'editCancel';
|
|
539
|
-
super[`${editCancel}`](args);
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
/**
|
|
543
|
-
* Handles the action of selecting a row when the context menu is opened.
|
|
544
|
-
*
|
|
545
|
-
* @param {Object} args - An object containing related parameters.
|
|
546
|
-
* @param {boolean} args.isOpen - A flag indicating whether the context menu is open.
|
|
547
|
-
* @returns {void} This method does not return any value.
|
|
548
|
-
*/
|
|
549
|
-
private toSelectRowOnContextOpen(args: { isOpen: boolean }): void {
|
|
550
|
-
const selectRowOnContextOpen: string = 'selectRowOnContextOpen';
|
|
551
|
-
super[`${selectRowOnContextOpen}`](args);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Restores a new row in the grid when necessary by adding it back to the content.
|
|
556
|
-
*
|
|
557
|
-
* @returns {void} This method does not return any value.
|
|
558
|
-
*/
|
|
559
|
-
private restoreNewRow(): void {
|
|
560
|
-
const isAdd: string = 'isAdd';
|
|
561
|
-
const content: HTMLElement = this.parent.getContent().querySelector('.e-content');
|
|
562
|
-
if (this[`${isAdd}`] && !content.querySelector('.e-addedrow')) {
|
|
563
|
-
this.parent.isEdit = false;
|
|
564
|
-
this.parent.editModule.addRecord(null, this.parent.root.editModule.selectedIndex);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
/**
|
|
569
|
-
* Retrieves virtual data for operations like adding or canceling rows in the grid.
|
|
570
|
-
*
|
|
571
|
-
* @param {Object} data - An object containing properties to determine the virtual data processing.
|
|
572
|
-
* @param {Object} data.virtualData - The virtual data object to be processed.
|
|
573
|
-
* @param {boolean} data.isAdd - A boolean indicating if the operation is an addition.
|
|
574
|
-
* @param {boolean} data.isCancel - A boolean indicating if the operation is a cancellation.
|
|
575
|
-
* @returns {void} This method does not return any value.
|
|
576
|
-
*/
|
|
577
|
-
private getData(data: { virtualData: Object, isAdd: boolean, isCancel: boolean }): void {
|
|
578
|
-
const getVirtualData: string = 'getVirtualData';
|
|
579
|
-
super[`${getVirtualData}`](data);
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* Initiates the beginning of an action within the tree grid component.
|
|
584
|
-
* This method is invoked before any action is performed, allowing for
|
|
585
|
-
* any necessary modifications or cancellations of the upcoming action.
|
|
586
|
-
*
|
|
587
|
-
* @param {NotifyArgs} args - The arguments associated with the action,
|
|
588
|
-
* providing context and specifics about what is being commenced.
|
|
589
|
-
* @returns {void}
|
|
590
|
-
*/
|
|
591
|
-
protected handleActionBegin(args: NotifyArgs): void {
|
|
592
|
-
const actionBegin: string = 'actionBegin';
|
|
593
|
-
super[`${actionBegin}`](args);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Handles the completion of various actions, such as adding a new row.
|
|
598
|
-
* Updates row positions and indexes based on the action completed.
|
|
599
|
-
*
|
|
600
|
-
* @param {NotifyArgs} args - An object containing the details of the completed action.
|
|
601
|
-
* Specifically, it includes the `requestType` which determines the type
|
|
602
|
-
* of action that was completed.
|
|
603
|
-
* @returns {void} This method does not return any value.
|
|
604
|
-
*/
|
|
605
|
-
private onActionComplete(args: NotifyArgs): void {
|
|
606
|
-
if (args.requestType === 'add') {
|
|
607
|
-
const addArgs: { newRowPosition: RowPosition, addRowIndex: number, dataRowIndex: number }
|
|
608
|
-
= { newRowPosition: this.rowPosition, addRowIndex: this.addRowIndex, dataRowIndex: this.dataRowIndex };
|
|
609
|
-
this.parent.notify('get-row-position', addArgs);
|
|
610
|
-
this.rowPosition = addArgs.newRowPosition;
|
|
611
|
-
this.addRowIndex = addArgs.addRowIndex;
|
|
612
|
-
this.dataRowIndex = this.parent.root.editModule.selectedIndex;
|
|
613
|
-
}
|
|
614
|
-
const actionComplete: string = 'actionComplete';
|
|
615
|
-
super[`${actionComplete}`](args);
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
/**
|
|
619
|
-
* Creates a callback function to be executed during virtual scrolling actions.
|
|
620
|
-
* This function handles the adjustment of virtual elements and rendering logic,
|
|
621
|
-
* particularly optimizing for non-IE browsers, wheel events, and virtual masks.
|
|
622
|
-
*
|
|
623
|
-
* @returns {Function} A function that handles scrolling and adjusts table rendering.
|
|
624
|
-
* @param {HTMLElement} element - The HTML element involved in the action.
|
|
625
|
-
* @param {SentinelType} current - The type of sentinel indicating the scroll.
|
|
626
|
-
* @param {string} direction - The scroll direction.
|
|
627
|
-
* @param {Offsets} e - The offset values indicating the current scroll position.
|
|
628
|
-
* @param {boolean} isWheel - Indicates if the scrolling was initiated by a mouse wheel.
|
|
629
|
-
* @param {boolean} check - A boolean flag for additional control logic.
|
|
630
|
-
*/
|
|
631
|
-
private onEnteredAction(): Function {
|
|
632
|
-
return (element: HTMLElement, current: SentinelType, direction: string, e: Offsets, isWheel: boolean, check: boolean) => {
|
|
633
|
-
const directVirtualRender: string = 'directVirtualRender';
|
|
634
|
-
if (!this.parent[`${directVirtualRender}`]) { // with this property, columns are rendered without debouncing on horizontal scroll.
|
|
635
|
-
const preventEvent: string = 'preventEvent';
|
|
636
|
-
if (Browser.isIE && !isWheel && check && !this[`${preventEvent}`] && !this.parent.enableVirtualMaskRow) {
|
|
637
|
-
this.parent.showSpinner();
|
|
638
|
-
}
|
|
639
|
-
if (this.parent.enableVirtualMaskRow && !this[`${preventEvent}`]) {
|
|
640
|
-
setTimeout(() => {
|
|
641
|
-
this.parent.showMaskRow(current.axis);
|
|
642
|
-
this.parent.notify('showGanttShimmer', { requestType: 'showShimmer'});
|
|
643
|
-
}, 0);
|
|
644
|
-
}
|
|
645
|
-
const height: number = this.content.getBoundingClientRect().height;
|
|
646
|
-
const top: number = this.prevInfo.offsets ? this.prevInfo.offsets.top : null;
|
|
647
|
-
const xAxis: boolean = current.axis === 'X';
|
|
648
|
-
let x: number = this.getColumnOffset(xAxis ? this.vgenerator.getColumnIndexes()[0] - 1 : this.prevInfo.columnIndexes[0]
|
|
649
|
-
- 1);
|
|
650
|
-
if (this.parent.isFrozenGrid() && this.parent.enableColumnVirtualization && this.currentInfo &&
|
|
651
|
-
this.currentInfo.columnIndexes) {
|
|
652
|
-
const cBlock: number = this.currentInfo.columnIndexes[0] - 1;
|
|
653
|
-
let frzLeftWidth: number = 0;
|
|
654
|
-
this.parent.getColumns().filter((col: Column) => {
|
|
655
|
-
if (col.visible && col.freeze === 'Left') {
|
|
656
|
-
frzLeftWidth += parseInt(col.width.toString(), 10);
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
if (cBlock > this.parent.getVisibleFrozenLeftCount()) {
|
|
660
|
-
x = x - frzLeftWidth;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
if (xAxis) {
|
|
664
|
-
const idx: number = Object.keys(this.vgenerator.cOffsets).length - this.prevInfo.columnIndexes.length;
|
|
665
|
-
const maxLeft: number = this.vgenerator.cOffsets[idx - 1];
|
|
666
|
-
x = x > maxLeft ? maxLeft : x; //TODO: This fix horizontal scrollbar jumping issue in column virtualization.
|
|
667
|
-
}
|
|
668
|
-
let y: number = this.getTranslateY(e.top, height, xAxis && top === e.top ? this.prevInfo : undefined, true);
|
|
669
|
-
if (!this.parent.isFrozenGrid() || this.parent.enableVirtualMaskRow) {
|
|
670
|
-
if (this.parent.enableVirtualMaskRow) {
|
|
671
|
-
const upScroll: boolean = (e.top - this.translateY) < 0;
|
|
672
|
-
y = (Math.round(this.translateY) > y && !upScroll) ? Math.round(this.translateY) : y;
|
|
673
|
-
this.virtualEle.adjustTable(x, y);
|
|
674
|
-
} else {
|
|
675
|
-
this.virtualEle.adjustTable(x, this.translateY);
|
|
676
|
-
}
|
|
677
|
-
if (this.parent.enableColumnVirtualization) {
|
|
678
|
-
this.header.virtualEle.adjustTable(x, 0);
|
|
679
|
-
if (this.parent.isFrozenGrid()) {
|
|
680
|
-
this.parent.contentModule['resetStickyLeftPos'](x);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
};
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* Handles scroll events to manage virtual scrolling and row rendering.
|
|
690
|
-
* Adjusts view information, row indexes, and translates viewport positioning
|
|
691
|
-
* based on the given scroll arguments.
|
|
692
|
-
*
|
|
693
|
-
* @param {ScrollArg} scrollArgs - Contains the scroll offsets, sentinel information, direction of scroll, and other related details.
|
|
694
|
-
* @returns {void} - No return value. It adjusts scrolling state internally.
|
|
695
|
-
*/
|
|
696
|
-
public scrollListeners(scrollArgs: ScrollArg) : void {
|
|
697
|
-
this['scrollAfterEdit']();
|
|
698
|
-
this.shouldPreventScrolling(scrollArgs);
|
|
699
|
-
if (this.parent.root.enablePersistence) {
|
|
700
|
-
this.parent.root.scrollPosition = scrollArgs.offset;
|
|
701
|
-
}
|
|
702
|
-
const info: SentinelType = scrollArgs.sentinel;
|
|
703
|
-
const rowHeight: number = this.parent.getRowHeight();
|
|
704
|
-
const outBuffer: number = this.parent.pageSettings.pageSize - Math.ceil(this.parent.pageSettings.pageSize / 2);
|
|
705
|
-
let content: HTMLElement;
|
|
706
|
-
if (!isNullOrUndefined(this.parent.contentModule)) {
|
|
707
|
-
content = this.parent.getContent().querySelector('.e-content');
|
|
708
|
-
}
|
|
709
|
-
const scrollHeight: number = outBuffer * rowHeight;
|
|
710
|
-
const upScroll: boolean = (scrollArgs.offset.top - this.translateY) < 0 && this.activeKey !== 'downArrow';
|
|
711
|
-
const downScroll: boolean = Math.ceil(scrollArgs.offset.top - this.translateY) + rowHeight >= scrollHeight;
|
|
712
|
-
const selectedRowIndex: string = 'selectedRowIndex';
|
|
713
|
-
const currentViewData: Object[] = this.parent.currentViewData; const indexValue: string = 'index';
|
|
714
|
-
if (upScroll && (scrollArgs.direction !== 'right' && scrollArgs.direction !== 'left') && !isNullOrUndefined(content)) {
|
|
715
|
-
const vHeight: number = +(this.parent.height.toString().indexOf('%') < 0 ? parseInt(this.parent.height.toString(), 10) :
|
|
716
|
-
this.parent.element.getBoundingClientRect().height);
|
|
717
|
-
// Calculate the integer number of rows that are scrolled past plus the number of rows that fit within the visible height
|
|
718
|
-
const scrolledRows: number = Math.floor(content.scrollTop / rowHeight);
|
|
719
|
-
const visibleRows: number = Math.ceil(vHeight / rowHeight);
|
|
720
|
-
|
|
721
|
-
// Calculate the index by subtracting the page size from the total rows taken into account
|
|
722
|
-
let index: number = scrolledRows + visibleRows - this.parent.pageSettings.pageSize;
|
|
723
|
-
index = (index > 0) ? index : 0;
|
|
724
|
-
if (!isNullOrUndefined(this[`${selectedRowIndex}`]) && this[`${selectedRowIndex}`] !== -1 && index !== this[`${selectedRowIndex}`] &&
|
|
725
|
-
((this.parent.rowHeight * this.parent.pageSettings.pageSize) < content.scrollTop) && !this.parent.allowRowDragAndDrop) {
|
|
726
|
-
index = this[`${selectedRowIndex}`];
|
|
727
|
-
}
|
|
728
|
-
this.startIndex = index;
|
|
729
|
-
this.endIndex = index + this.parent.pageSettings.pageSize;
|
|
730
|
-
if (this.endIndex > this.totalRecords) {
|
|
731
|
-
const lastInx: number = this.totalRecords;
|
|
732
|
-
const remains: number = this.endIndex % lastInx;
|
|
733
|
-
this.endIndex = lastInx;
|
|
734
|
-
this.startIndex = (this.startIndex - remains) < 0 ? 0 : (this.startIndex - remains);
|
|
735
|
-
}
|
|
736
|
-
if (currentViewData.length && (currentViewData[0][`${indexValue}`] >= this.parent.pageSettings.pageSize / 2) &&
|
|
737
|
-
((currentViewData[0][`${indexValue}`] - this.startIndex) < (this.parent.pageSettings.pageSize / 2)) &&
|
|
738
|
-
this.parent.selectionModule && this.parent.selectionModule.isRowSelected) {
|
|
739
|
-
this.startIndex = currentViewData[0][`${indexValue}`] - (this.parent.pageSettings.pageSize / 2);
|
|
740
|
-
this.endIndex = this.startIndex + this.parent.pageSettings.pageSize;
|
|
741
|
-
}
|
|
742
|
-
//var firsttdinx = parseInt(this.parent.getContent().querySelector('.e-content td').getAttribute('index'), 0);
|
|
743
|
-
let rowPt: number = Math.ceil(scrollArgs.offset.top / rowHeight);
|
|
744
|
-
rowPt = rowPt % this.parent.pageSettings.pageSize;
|
|
745
|
-
let firsttdinx: number = 0;
|
|
746
|
-
if (!isNullOrUndefined(this.parent.getRows()[parseInt(rowPt.toString(), 10)]) &&
|
|
747
|
-
!isNullOrUndefined(this.parent.getContent().querySelectorAll('.e-content tr')[parseInt(rowPt.toString(), 10)])) {
|
|
748
|
-
const attr: string = this.parent.getContent().querySelectorAll('.e-content tr')[parseInt(rowPt.toString(), 10)]
|
|
749
|
-
.querySelector('td').getAttribute('index');
|
|
750
|
-
firsttdinx = +attr; // this.parent.getContent().querySelector('.e-content tr').getAttribute('data-rowindex');
|
|
751
|
-
}
|
|
752
|
-
if (firsttdinx === 0) {
|
|
753
|
-
if (this.endIndex - this.startIndex < this.parent.pageSettings.pageSize) {
|
|
754
|
-
this.translateY = !isNullOrUndefined(this.endIndex) ?
|
|
755
|
-
(this.endIndex - this.parent.pageSettings.pageSize) * (this.parent.rowHeight ?
|
|
756
|
-
this.parent.rowHeight : this.parent.getRowHeight()) : 0;
|
|
757
|
-
}
|
|
758
|
-
else if (this.startIndex === this[`${selectedRowIndex}`]) {
|
|
759
|
-
this.translateY = scrollArgs.offset.top;
|
|
760
|
-
}
|
|
761
|
-
else {
|
|
762
|
-
this.translateY = (scrollArgs.offset.top - (outBuffer * rowHeight) > 0) ?
|
|
763
|
-
scrollArgs.offset.top - (outBuffer * rowHeight) + rowHeight : 0;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
else if (this.parent.getFrozenColumns() > 0) {
|
|
767
|
-
scrollArgs.offset.top = scrollArgs.offset.top + 80;
|
|
768
|
-
this.translateY = (scrollArgs.offset.top - (outBuffer * rowHeight) > 0) ?
|
|
769
|
-
scrollArgs.offset.top - (outBuffer * rowHeight) + 10 : 0;
|
|
770
|
-
}
|
|
771
|
-
else {
|
|
772
|
-
this.translateY = (scrollArgs.offset.top - (outBuffer * rowHeight) > 0) ?
|
|
773
|
-
scrollArgs.offset.top - (outBuffer * rowHeight) + 10 : 0;
|
|
774
|
-
}
|
|
775
|
-
} else if (downScroll && (scrollArgs.direction !== 'right' && scrollArgs.direction !== 'left') && !isNullOrUndefined(content)) {
|
|
776
|
-
let nextSetResIndex: number = ~~(content.scrollTop / rowHeight);
|
|
777
|
-
const isLastBlock: boolean = (this[`${selectedRowIndex}`] + this.parent.pageSettings.pageSize) < this.totalRecords ? false : true;
|
|
778
|
-
if (!isNullOrUndefined(this[`${selectedRowIndex}`]) && this[`${selectedRowIndex}`] !== -1 &&
|
|
779
|
-
nextSetResIndex !== this[`${selectedRowIndex}`] && !isLastBlock && !this.parent.allowRowDragAndDrop) {
|
|
780
|
-
nextSetResIndex = this[`${selectedRowIndex}`];
|
|
781
|
-
}
|
|
782
|
-
let lastIndex: number = nextSetResIndex + this.parent.pageSettings.pageSize;
|
|
783
|
-
if (lastIndex > this.totalRecords) {
|
|
784
|
-
lastIndex = nextSetResIndex +
|
|
785
|
-
(this.totalRecords - nextSetResIndex);
|
|
786
|
-
}
|
|
787
|
-
this.startIndex = !isLastBlock || isNullOrUndefined(this['' + selectedRowIndex]) ? lastIndex - this.parent.pageSettings.pageSize : nextSetResIndex;
|
|
788
|
-
this.endIndex = lastIndex;
|
|
789
|
-
if ((nextSetResIndex + this.parent.pageSettings.pageSize) > this.totalRecords && (this.endIndex - this.startIndex) <
|
|
790
|
-
(this.parent.pageSettings.pageSize / 2) && (this.endIndex - nextSetResIndex) < (this.parent.pageSettings.pageSize / 2)) {
|
|
791
|
-
this.startIndex = lastIndex - (this.parent.pageSettings.pageSize / 2);
|
|
792
|
-
}
|
|
793
|
-
if (scrollArgs.offset.top > (rowHeight * this.totalRecords)) {
|
|
794
|
-
this.translateY = this.getTranslateY(scrollArgs.offset.top, content.getBoundingClientRect().height);
|
|
795
|
-
} else {
|
|
796
|
-
if (this.totalRecords === this.endIndex) {
|
|
797
|
-
if (this.totalRecords === this.endIndex) {
|
|
798
|
-
if (this.parent.isEdit) {
|
|
799
|
-
this.translateY = ((this.totalRecords * rowHeight) - (this.parent.pageSettings.pageSize * rowHeight))
|
|
800
|
-
+ rowHeight;
|
|
801
|
-
} else {
|
|
802
|
-
this.translateY = (this.totalRecords * rowHeight) - (this.parent.pageSettings.pageSize * rowHeight);
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
else {
|
|
807
|
-
if (this.parent.getFrozenColumns() > 0) {
|
|
808
|
-
this.translateY = scrollArgs.offset.top - ((rowHeight * 2) + this.parent.pageSettings.pageSize);
|
|
809
|
-
}
|
|
810
|
-
else {
|
|
811
|
-
this.translateY = scrollArgs.offset.top;
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
if (((downScroll && scrollArgs.direction !== 'up' && (scrollArgs.offset.top < (rowHeight * this.totalRecords)))
|
|
817
|
-
|| (upScroll)) || (scrollArgs.direction === 'right' || scrollArgs.direction === 'left') ||
|
|
818
|
-
((this.parent.dataSource instanceof DataManager && (this.parent.dataSource as DataManager).dataSource.url !== undefined
|
|
819
|
-
&& !(this.parent.dataSource as DataManager).dataSource.offline && (this.parent.dataSource as DataManager).dataSource.url !== ''))
|
|
820
|
-
) {
|
|
821
|
-
const viewInfo: VirtualInfo = this.currentInfo = getValue('getInfoFromView', this).apply(this, [scrollArgs.direction, info, scrollArgs.offset]);
|
|
822
|
-
this.previousInfo = viewInfo;
|
|
823
|
-
if (this.prevInfo && (isRemoteData(this.parent.root) && viewInfo.event !== 'model-changed') && ((info.axis === 'Y' && this.prevInfo.blockIndexes.toString() === viewInfo.blockIndexes.toString())
|
|
824
|
-
|| ((info.axis === 'X' && this.prevInfo.columnIndexes.toString() === viewInfo.columnIndexes.toString())
|
|
825
|
-
|| (this.parent.isFrozenGrid() && this.parent.getVisibleFrozenLeftCount() >= viewInfo.columnIndexes[0]
|
|
826
|
-
&& this.prevInfo.columnIndexes.toString().includes(viewInfo.columnIndexes.toString()))))) {
|
|
827
|
-
this.parent.removeMaskRow();
|
|
828
|
-
this.parent.notify('removeGanttShimmer', { requestType: 'hideShimmer'});
|
|
829
|
-
if (Browser.isIE) {
|
|
830
|
-
this.parent.hideSpinner();
|
|
831
|
-
}
|
|
832
|
-
this.requestType = this.requestType === 'virtualscroll' ? this['empty'] as string : this.requestType;
|
|
833
|
-
if (info.axis === 'Y') {
|
|
834
|
-
this.restoreEditState();
|
|
835
|
-
}
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
838
|
-
this.parent.setColumnIndexesInView(this.parent.enableColumnVirtualization ? viewInfo.columnIndexes : []);
|
|
839
|
-
const page: number = viewInfo.loadNext && !viewInfo.loadSelf ? viewInfo.nextInfo.page : viewInfo.page;
|
|
840
|
-
this.parent.setProperties({ pageSettings: { currentPage: page } }, true);
|
|
841
|
-
// if (downScroll && this.endIndex === this.totalRecords && viewInfo.loadNext) {
|
|
842
|
-
// viewInfo.loadNext = false;
|
|
843
|
-
// }
|
|
844
|
-
this.requestType = 'virtualscroll';
|
|
845
|
-
if (scrollArgs.direction !== 'right' && scrollArgs.direction !== 'left' && !isRemoteData(this.parent.root)) {
|
|
846
|
-
viewInfo.event = viewInfo.event === 'refresh-virtual-block' ? 'model-changed' : viewInfo.event;
|
|
847
|
-
}
|
|
848
|
-
if (this.parent.enableVirtualMaskRow) {
|
|
849
|
-
this.parent.showMaskRow(info.axis);
|
|
850
|
-
this.parent.addShimmerEffect();
|
|
851
|
-
this.parent.notify('showGanttShimmer', { requestType: 'showShimmer'});
|
|
852
|
-
}
|
|
853
|
-
this.parent.notify(viewInfo.event, { requestType: 'virtualscroll', virtualInfo: viewInfo, focusElement: scrollArgs.focusElement });
|
|
854
|
-
} else {
|
|
855
|
-
if (this.parent.enableVirtualMaskRow) {
|
|
856
|
-
this.parent.removeMaskRow();
|
|
857
|
-
this.parent.notify('removeGanttShimmer', { requestType: 'hideShimmer'});
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
/**
|
|
863
|
-
* Prevents scrolling under specific conditions related to adding a new row.
|
|
864
|
-
*
|
|
865
|
-
* @param {ScrollArg} scrollArgs - The scroll event arguments containing offset details.
|
|
866
|
-
* @returns {void}
|
|
867
|
-
*/
|
|
868
|
-
private shouldPreventScrolling(scrollArgs: ScrollArg): void {
|
|
869
|
-
const addedRow: any = this.parent.element.querySelector('.e-addedrow');
|
|
870
|
-
if (addedRow && this.rowPosition !== 'Top' && this.rowPosition !== 'Bottom' && scrollArgs.offset.top !== 0) {
|
|
871
|
-
this.parent.closeEdit();
|
|
872
|
-
return;
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
/**
|
|
877
|
-
* Appends content to the target element. Handles dynamic adjustments for remote data sources,
|
|
878
|
-
* frozen columns, and virtual scrolling.
|
|
879
|
-
*
|
|
880
|
-
* @param {HTMLElement} target - The target HTML element where content is to be appended.
|
|
881
|
-
* @param {DocumentFragment} newChild - The new content as a DocumentFragment to append.
|
|
882
|
-
* @param {NotifyArgs} e - Object containing information about the operation.
|
|
883
|
-
* @returns {void}
|
|
884
|
-
*/
|
|
885
|
-
public appendContent(target: HTMLElement, newChild: DocumentFragment, e: NotifyArgs) : void {
|
|
886
|
-
if ((this.parent.dataSource instanceof DataManager && (this.parent.dataSource as DataManager).dataSource.url !== undefined
|
|
887
|
-
&& !(this.parent.dataSource as DataManager).dataSource.offline && (this.parent.dataSource as DataManager).dataSource.url !== '') || isCountRequired(this.parent)
|
|
888
|
-
|| (this.parent.isFrozenGrid() && (e.requestType === undefined || !isNullOrUndefined(e.virtualInfo) && (e.virtualInfo.direction === 'right' || e.virtualInfo.direction === 'left' )))) {
|
|
889
|
-
if (getValue('isExpandCollapse', e)) {
|
|
890
|
-
this.isRemoteExpand = true;
|
|
891
|
-
}
|
|
892
|
-
super.appendContent(target, newChild, e);
|
|
893
|
-
if (getValue('requestTypes', this).indexOf('isFrozen') !== -1){
|
|
894
|
-
getValue('requestTypes', this).splice(getValue('requestTypes', this).indexOf('isFrozen'), 1);
|
|
895
|
-
this.requestType = this.requestType === 'isFrozen' ? undefined : this.requestType;
|
|
896
|
-
}
|
|
897
|
-
} else {
|
|
898
|
-
const info: VirtualInfo = e.virtualInfo.sentinelInfo && e.virtualInfo.sentinelInfo.axis === 'Y' &&
|
|
899
|
-
getValue('currentInfo', this).page && getValue('currentInfo', this).page !== e.virtualInfo.page ?
|
|
900
|
-
getValue('currentInfo', this) : e.virtualInfo;
|
|
901
|
-
const cBlock: number = (info.columnIndexes[0]) - 1;
|
|
902
|
-
let cOffset: number = this.getColumnOffset(cBlock); let width: string;
|
|
903
|
-
if (this.parent.enableColumnVirtualization) {
|
|
904
|
-
this.header.virtualEle.adjustTable(cOffset, 0);
|
|
905
|
-
const cIndex: number[] = info.columnIndexes;
|
|
906
|
-
width = this.getColumnOffset(cIndex[cIndex.length - 1]) - this.getColumnOffset(cIndex[0] - 1) + '';
|
|
907
|
-
this.header.virtualEle.setWrapperWidth(width);
|
|
908
|
-
}
|
|
909
|
-
this.virtualEle.setWrapperWidth(width, ( Browser.isIE || Browser.info.name === 'edge') as boolean);
|
|
910
|
-
target = this.parent.createElement('tbody');
|
|
911
|
-
target.appendChild(newChild);
|
|
912
|
-
const replace: string = 'replaceWith';
|
|
913
|
-
(this.getTable().querySelector('tbody') as HTMLElement)[`${replace}`](target);
|
|
914
|
-
if (e.requestType === 'virtualscroll' && e.virtualInfo.sentinelInfo.axis === 'Y') {
|
|
915
|
-
this.isExpandCollapse = false;
|
|
916
|
-
}
|
|
917
|
-
let reduceWidth: number = 0;
|
|
918
|
-
if (this.parent.enableColumnVirtualization && this.parent.isFrozenGrid()) {
|
|
919
|
-
let frzLeftWidth: number = 0;
|
|
920
|
-
this.parent.getColumns().filter((col: Column) => {
|
|
921
|
-
if (col.visible) {
|
|
922
|
-
reduceWidth += parseInt(col.width.toString(), 10);
|
|
923
|
-
if (col.freeze === 'Left') {
|
|
924
|
-
frzLeftWidth += parseInt(col.width.toString(), 10);
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
});
|
|
928
|
-
const cIndex: number[] = info.columnIndexes;
|
|
929
|
-
width = this.getColumnOffset(cIndex[cIndex.length - 1]) - this.getColumnOffset(cIndex[0] - 1) + '';
|
|
930
|
-
if (cBlock > this.parent.getVisibleFrozenLeftCount()) {
|
|
931
|
-
cOffset = cOffset - frzLeftWidth;
|
|
932
|
-
}
|
|
933
|
-
this.resetStickyLeftPos(cOffset, newChild);
|
|
934
|
-
}
|
|
935
|
-
if (!this.isExpandCollapse || this.translateY === 0) {
|
|
936
|
-
this.translateY = this.translateY < 0 ? 0 : this.translateY;
|
|
937
|
-
getValue('virtualEle', this).adjustTable(cOffset, this.translateY);
|
|
938
|
-
if (this.parent.enableColumnVirtualization) {
|
|
939
|
-
this.header.virtualEle.adjustTable(cOffset, 0);
|
|
940
|
-
if (this.parent.isFrozenGrid()) {
|
|
941
|
-
this.resetStickyLeftPos(cOffset);
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
} else {
|
|
945
|
-
this.isExpandCollapse = false;
|
|
946
|
-
}
|
|
947
|
-
setValue('prevInfo', this.previousInfo ? this.previousInfo : info, this);
|
|
948
|
-
if (e.requestType === 'virtualscroll' && e.virtualInfo.sentinelInfo.axis === 'X') {
|
|
949
|
-
this.parent.notify(events.autoCol, {});
|
|
950
|
-
}
|
|
951
|
-
const focusCell: string = 'focusCell'; const restoreAdd: string = 'restoreAdd';
|
|
952
|
-
const ensureSelectedRowPosition: string = 'ensureSelectedRowPosition';
|
|
953
|
-
super[`${focusCell}`](e);
|
|
954
|
-
const isAdd: string = 'isAdd';
|
|
955
|
-
if (this[`${isAdd}`] && !this.parent.getContent().querySelector('.e-content').querySelector('.e-addedrow')) {
|
|
956
|
-
if (!(this.rowPosition === 'Top' || this.rowPosition === 'Bottom')) {
|
|
957
|
-
if (this.dataRowIndex >= this.startIndex) {
|
|
958
|
-
this.restoreNewRow();
|
|
959
|
-
} else if (this.addRowIndex && this.addRowIndex > -1) {
|
|
960
|
-
this[`${isAdd}`] = false;
|
|
961
|
-
this.parent.isEdit = false;
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
this.restoreEditState();
|
|
966
|
-
super[`${restoreAdd}`]();
|
|
967
|
-
super[`${ensureSelectedRowPosition}`]();
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
/**
|
|
972
|
-
* Unsubscribes all event listeners to prevent memory leaks.
|
|
973
|
-
* This method is called when the component is being destroyed or when event listeners need to be cleaned up.
|
|
974
|
-
*
|
|
975
|
-
* @returns {void}
|
|
976
|
-
*/
|
|
977
|
-
public removeEventListener(): void {
|
|
978
|
-
if (this.parent.isDestroyed) { return; }
|
|
979
|
-
this.parent.off('data-ready', this.onDataReady);
|
|
980
|
-
this.parent.off('content-ready', this.fn);
|
|
981
|
-
this.parent.off('select-virtual-Row', this.toSelectVirtualRow);
|
|
982
|
-
this.parent.off('dataBound', this.dataBoundEvent);
|
|
983
|
-
this.parent.off('rowSelected', this.rowSelectedEvent);
|
|
984
|
-
this.parent.off(events.virtualActionArgs, this.virtualOtherAction);
|
|
985
|
-
this.parent.off(events.indexModifier, this.indexModifier);
|
|
986
|
-
this.parent.off('virtual-scroll-edit-action-begin', this.beginEdit);
|
|
987
|
-
this.parent.off('virtual-scroll-add-action-begin', this.beginAdd);
|
|
988
|
-
this.parent.off('virtual-scroll-edit-success', this.virtualEditSuccess);
|
|
989
|
-
this.parent.off('edit-reset', this.resetIseditValue);
|
|
990
|
-
this.parent.off('get-virtual-data', this.getData);
|
|
991
|
-
this.parent.off('virtual-scroll-edit-cancel', this.cancelEdit);
|
|
992
|
-
this.parent.off('select-row-on-context-open', this.toSelectRowOnContextOpen);
|
|
993
|
-
this.parent.off('refresh-virtual-editform-cells', this.refreshCell);
|
|
994
|
-
this.parent.off('virtaul-cell-focus', this.cellFocus);
|
|
995
|
-
this.parent.off('virtual-scroll-edit', this.restoreEditState);
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
export class TreeInterSectionObserver extends InterSectionObserver {
|
|
1001
|
-
private isWheeling: boolean = false;
|
|
1002
|
-
private newPos: number = 0;
|
|
1003
|
-
private lastPos: number = 0;
|
|
1004
|
-
private timer: number = 0;
|
|
1005
|
-
|
|
1006
|
-
/**
|
|
1007
|
-
* Sets up observers to monitor scroll events on a given container
|
|
1008
|
-
* and its movable companion within a virtual grid setup.
|
|
1009
|
-
*
|
|
1010
|
-
* @param {Function} callback - Function to call when a scroll event is detected.
|
|
1011
|
-
* @param {Function} onEnterCallback - Function to call when a specific event, like entering a region, is detected.
|
|
1012
|
-
* @param {IGrid} instance - The grid instance that requires observation.
|
|
1013
|
-
* @returns {void}
|
|
1014
|
-
*/
|
|
1015
|
-
public observes(callback: Function, onEnterCallback: Function, instance: IGrid): void {
|
|
1016
|
-
const containerRect: string = 'containerRect';
|
|
1017
|
-
super[`${containerRect}`] = getValue('options', this).container.getBoundingClientRect();
|
|
1018
|
-
EventHandler.add(getValue('options', this).container, 'scroll', this.virtualScrollHandlers(callback, onEnterCallback, instance), this);
|
|
1019
|
-
if (getValue('options', this).movableContainer) {
|
|
1020
|
-
const movableContainerRect: string = 'movableContainerRect';
|
|
1021
|
-
super[`${movableContainerRect}`] = getValue('options', this).movableContainer.getBoundingClientRect();
|
|
1022
|
-
EventHandler.add(getValue('options', this).movableContainer, 'scroll', this.virtualScrollHandlers(callback, onEnterCallback, instance), this);
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
/**
|
|
1027
|
-
* Clears the last known position.
|
|
1028
|
-
*
|
|
1029
|
-
* @returns {void} No value is returned from this function.
|
|
1030
|
-
*/
|
|
1031
|
-
private clear(): void {
|
|
1032
|
-
this.lastPos = null;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
/**
|
|
1036
|
-
* Handles virtual scrolling events and manages scroll direction and debouncing for rendering updates.
|
|
1037
|
-
*
|
|
1038
|
-
* @private
|
|
1039
|
-
* @param {Function} callback - Function to call on scroll end.
|
|
1040
|
-
* @param {Function} onEnterCallback - Function to call on entering a virtual scrolling area.
|
|
1041
|
-
* @param {IGrid} instance - The grid instance on which virtual scrolling is being implemented.
|
|
1042
|
-
* @returns {Function} - A function that processes scroll events.
|
|
1043
|
-
*/
|
|
1044
|
-
private virtualScrollHandlers(callback: Function, onEnterCallback: Function, instance: IGrid) : Function {
|
|
1045
|
-
const delay: number = Browser.info.name === 'chrome' ? 200 : 100;
|
|
1046
|
-
const options: string = 'options'; const movableEle: string = 'movableEle';
|
|
1047
|
-
const element: string = 'element'; const fromWheel: string = 'fromWheel';
|
|
1048
|
-
const debounced100: Function = debounce(callback, delay);
|
|
1049
|
-
const debounced50: Function = debounce(callback, 50);
|
|
1050
|
-
this[`${options}`].prevTop = this[`${options}`].prevLeft = 0;
|
|
1051
|
-
const isScrollByFocus: string = 'isScrollByFocus';
|
|
1052
|
-
return (e: Event) => {
|
|
1053
|
-
const keyPress: string = 'keyPress';
|
|
1054
|
-
let keyaction: any;
|
|
1055
|
-
if (instance && instance.root && instance.root.editModule && instance.root.editModule[`${keyPress}`]) {
|
|
1056
|
-
keyaction = instance.root.editModule[`${keyPress}`];
|
|
1057
|
-
}
|
|
1058
|
-
if ((instance.isEdit && instance.root.editModule[`${isScrollByFocus}`]) || (instance.isEdit && (keyaction === 'tab' || keyaction === 'shiftTab'))) {
|
|
1059
|
-
instance.root.editModule[`${isScrollByFocus}`] = false;
|
|
1060
|
-
return;
|
|
1061
|
-
}
|
|
1062
|
-
const top: number = this[`${options}`].movableContainer ? this[`${options}`].container.scrollTop : (<HTMLElement>e.target).scrollTop;
|
|
1063
|
-
const left: number = this[`${options}`].movableContainer ? this[`${options}`].scrollbar.scrollLeft : (<HTMLElement>e.target).scrollLeft;
|
|
1064
|
-
let direction: ScrollDirection = this[`${options}`].prevTop < top ? 'down' : 'up';
|
|
1065
|
-
direction = this[`${options}`].prevLeft === left ? direction : this[`${options}`].prevLeft < left ? 'right' : 'left';
|
|
1066
|
-
this[`${options}`].prevTop = top; this[`${options}`].prevLeft = left;
|
|
1067
|
-
|
|
1068
|
-
const current: SentinelType = this.sentinelInfo[`${direction}`];
|
|
1069
|
-
|
|
1070
|
-
let delta: number = 0;
|
|
1071
|
-
this.newPos = top;
|
|
1072
|
-
if ( this.lastPos != null ) { // && newPos < maxScroll
|
|
1073
|
-
delta = this.newPos - this.lastPos;
|
|
1074
|
-
}
|
|
1075
|
-
this.lastPos = this.newPos;
|
|
1076
|
-
if (this.timer) {
|
|
1077
|
-
clearTimeout(this.timer);
|
|
1078
|
-
}
|
|
1079
|
-
this.timer = setTimeout(this.clear, 0);
|
|
1080
|
-
if ((delta > 100 || delta < -100) && (e && e.preventDefault)) {
|
|
1081
|
-
e.returnValue = false;
|
|
1082
|
-
e.preventDefault();
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
if (this[`${options}`].axes.indexOf(current.axis) === -1) {
|
|
1087
|
-
return;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
const containerRect: string = 'containerRect';
|
|
1091
|
-
this[`${containerRect}`] = this[`${options}`].container.getBoundingClientRect();
|
|
1092
|
-
const check: boolean = this.check(direction);
|
|
1093
|
-
if (current.entered && (current.axis === 'X' || instance.enableVirtualMaskRow)) {
|
|
1094
|
-
if (this[`${movableEle}`] && (direction === 'right' || direction === 'left')) {
|
|
1095
|
-
onEnterCallback(this[`${movableEle}`], current, direction, { top: top, left: left }, this[`${fromWheel}`], check);
|
|
1096
|
-
} else {
|
|
1097
|
-
onEnterCallback(this[`${element}`], current, direction, { top: top, left: left }, this[`${fromWheel}`], check);
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
if (check) {
|
|
1101
|
-
let fn: Function = debounced50;
|
|
1102
|
-
if (current.axis === 'X') {
|
|
1103
|
-
fn({ direction: direction, sentinel: current, offset: { top: top, left: left },
|
|
1104
|
-
focusElement: document.activeElement});
|
|
1105
|
-
}
|
|
1106
|
-
else {
|
|
1107
|
-
if ((instance.dataSource instanceof DataManager && (instance.dataSource as DataManager).dataSource.url !== undefined
|
|
1108
|
-
&& !(instance.dataSource as DataManager).dataSource.offline && (instance.dataSource as DataManager).dataSource.url !== '') || isCountRequired(instance)
|
|
1109
|
-
|| instance.enableVirtualMaskRow) {
|
|
1110
|
-
fn = instance.enableVirtualMaskRow ? debounced100 : fn;
|
|
1111
|
-
fn({ direction: direction, sentinel: current, offset: { top: top, left: left },
|
|
1112
|
-
focusElement: document.activeElement});
|
|
1113
|
-
}
|
|
1114
|
-
else {
|
|
1115
|
-
callback({ direction: direction, sentinel: current, offset: { top: top, left: left },
|
|
1116
|
-
focusElement: document.activeElement});
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
this[`${fromWheel}`] = false;
|
|
1121
|
-
};
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
type ScrollArg = { direction: string, isWheel: boolean, sentinel: SentinelType, offset: Offsets, focusElement: HTMLElement };
|
|
1125
|
-
type ScrollDirection = 'up' | 'down' | 'right' | 'left';
|