@syncfusion/ej2-treegrid 26.1.35-469198 → 26.1.35-760834

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.
Files changed (111) hide show
  1. package/dist/ej2-treegrid.min.js +1 -1
  2. package/dist/ej2-treegrid.umd.min.js +1 -1
  3. package/dist/ej2-treegrid.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-treegrid.es2015.js +156 -35
  5. package/dist/es6/ej2-treegrid.es2015.js.map +1 -1
  6. package/dist/es6/ej2-treegrid.es5.js +158 -35
  7. package/dist/es6/ej2-treegrid.es5.js.map +1 -1
  8. package/dist/global/ej2-treegrid.min.js +1 -1
  9. package/dist/global/ej2-treegrid.min.js.map +1 -1
  10. package/dist/ts/undefined +73 -602
  11. package/index.d.ts +4 -0
  12. package/index.js +4 -0
  13. package/package.json +1 -1
  14. package/src/index.d.ts +4 -0
  15. package/src/treegrid/actions/batch-edit.d.ts +73 -0
  16. package/src/treegrid/actions/clipboard.d.ts +36 -0
  17. package/src/treegrid/actions/column-chooser.d.ts +37 -0
  18. package/src/treegrid/actions/column-menu.d.ts +24 -0
  19. package/src/treegrid/actions/command-column.d.ts +24 -0
  20. package/src/treegrid/actions/context-menu.d.ts +42 -0
  21. package/src/treegrid/actions/crud-actions.d.ts +66 -0
  22. package/src/treegrid/actions/crud-actions.js +1 -1
  23. package/src/treegrid/actions/detail-row.d.ts +39 -0
  24. package/src/treegrid/actions/edit.d.ts +112 -0
  25. package/src/treegrid/actions/edit.js +3 -2
  26. package/src/treegrid/actions/excel-export.d.ts +59 -0
  27. package/src/treegrid/actions/excel-export.js +14 -3
  28. package/src/treegrid/actions/filter.d.ts +57 -0
  29. package/src/treegrid/actions/freeze-column.d.ts +28 -0
  30. package/src/treegrid/actions/index.d.ts +24 -0
  31. package/src/treegrid/actions/infinite-scroll.d.ts +96 -0
  32. package/src/treegrid/actions/logger.d.ts +25 -0
  33. package/src/treegrid/actions/page.d.ts +67 -0
  34. package/src/treegrid/actions/pdf-export.d.ts +55 -0
  35. package/src/treegrid/actions/print.d.ts +37 -0
  36. package/src/treegrid/actions/reorder.d.ts +36 -0
  37. package/src/treegrid/actions/resize.d.ts +36 -0
  38. package/src/treegrid/actions/rowdragdrop.d.ts +113 -0
  39. package/src/treegrid/actions/rowdragdrop.js +2 -2
  40. package/src/treegrid/actions/selection.d.ts +51 -0
  41. package/src/treegrid/actions/selection.js +9 -0
  42. package/src/treegrid/actions/sort.d.ts +63 -0
  43. package/src/treegrid/actions/summary.d.ts +47 -0
  44. package/src/treegrid/actions/toolbar.d.ts +52 -0
  45. package/src/treegrid/actions/virtual-scroll.d.ts +55 -0
  46. package/src/treegrid/actions/virtual-scroll.js +13 -1
  47. package/src/treegrid/base/constant.d.ts +162 -0
  48. package/src/treegrid/base/data.d.ts +90 -0
  49. package/src/treegrid/base/data.js +20 -3
  50. package/src/treegrid/base/index.d.ts +11 -0
  51. package/src/treegrid/base/interface.d.ts +182 -0
  52. package/src/treegrid/base/treegrid.d.ts +2190 -0
  53. package/src/treegrid/base/treegrid.js +86 -17
  54. package/src/treegrid/enum.d.ts +155 -0
  55. package/src/treegrid/index.d.ts +9 -0
  56. package/src/treegrid/models/column.d.ts +752 -0
  57. package/src/treegrid/models/edit-settings.d.ts +90 -0
  58. package/src/treegrid/models/filter-settings.d.ts +203 -0
  59. package/src/treegrid/models/index.d.ts +24 -0
  60. package/src/treegrid/models/infinite-scroll-settings.d.ts +25 -0
  61. package/src/treegrid/models/loading-indicator.d.ts +19 -0
  62. package/src/treegrid/models/page-settings.d.ts +60 -0
  63. package/src/treegrid/models/rowdrop-settings.d.ts +27 -0
  64. package/src/treegrid/models/search-settings.d.ts +71 -0
  65. package/src/treegrid/models/selection-settings.d.ts +79 -0
  66. package/src/treegrid/models/sort-settings.d.ts +40 -0
  67. package/src/treegrid/models/summary.d.ts +124 -0
  68. package/src/treegrid/models/textwrap-settings.d.ts +16 -0
  69. package/src/treegrid/renderer/index.d.ts +5 -0
  70. package/src/treegrid/renderer/render.d.ts +41 -0
  71. package/src/treegrid/renderer/virtual-row-model-generator.d.ts +16 -0
  72. package/src/treegrid/renderer/virtual-tree-content-render.d.ts +75 -0
  73. package/src/treegrid/renderer/virtual-tree-content-render.js +11 -6
  74. package/src/treegrid/utils.d.ts +70 -0
  75. package/styles/bootstrap5.3-lite.css +2 -1090
  76. package/styles/bootstrap5.3.css +3 -1091
  77. package/styles/fluent2-lite.css +8 -1129
  78. package/styles/fluent2.css +8 -1129
  79. package/styles/material3-dark-lite.css +10 -1098
  80. package/styles/material3-dark.css +10 -1098
  81. package/styles/material3-lite.css +10 -1098
  82. package/styles/material3.css +10 -1098
  83. package/styles/tailwind3-lite.css +77 -1213
  84. package/styles/tailwind3.css +84 -1220
  85. package/styles/treegrid/_bds-definition.scss +0 -25
  86. package/styles/treegrid/_bigger.scss +6 -6
  87. package/styles/treegrid/_bootstrap-dark-definition.scss +0 -25
  88. package/styles/treegrid/_bootstrap-definition.scss +0 -25
  89. package/styles/treegrid/_bootstrap4-definition.scss +0 -25
  90. package/styles/treegrid/_bootstrap5-definition.scss +0 -25
  91. package/styles/treegrid/_bootstrap5.3-definition.scss +0 -25
  92. package/styles/treegrid/_fabric-dark-definition.scss +0 -25
  93. package/styles/treegrid/_fabric-definition.scss +0 -25
  94. package/styles/treegrid/_fluent-definition.scss +0 -25
  95. package/styles/treegrid/_fluent2-definition.scss +0 -25
  96. package/styles/treegrid/_fusionnew-definition.scss +0 -25
  97. package/styles/treegrid/_highcontrast-definition.scss +0 -25
  98. package/styles/treegrid/_highcontrast-light-definition.scss +0 -25
  99. package/styles/treegrid/_layout.scss +29 -29
  100. package/styles/treegrid/_material-dark-definition.scss +0 -25
  101. package/styles/treegrid/_material-definition.scss +0 -25
  102. package/styles/treegrid/_material3-definition.scss +0 -25
  103. package/styles/treegrid/_tailwind-definition.scss +0 -25
  104. package/styles/treegrid/_tailwind3-definition.scss +17 -42
  105. package/styles/treegrid/bootstrap5.3.css +3 -1091
  106. package/styles/treegrid/fluent2.css +8 -1129
  107. package/styles/treegrid/material3-dark.css +10 -1098
  108. package/styles/treegrid/material3.css +10 -1098
  109. package/styles/treegrid/tailwind3.css +84 -1220
  110. package/treegrid.d.ts +4 -0
  111. package/treegrid.js +4 -0
package/dist/ts/undefined CHANGED
@@ -1,602 +1,73 @@
1
- import { ITreeData } from '../base/interface';
2
- import { isNullOrUndefined, extend, setValue, getValue } from '@syncfusion/ej2-base';
3
- import { TreeGrid } from '../base';
4
- import * as events from '../base/constant';
5
- import { DataManager } from '@syncfusion/ej2-data';
6
- import { findChildrenRecords, getParentData, extendArray } from '../utils';
7
- import { BeforeBatchSaveArgs, getUid, CellSaveArgs, NotifyArgs, Column, Row, BatchChanges, BeforeBatchDeleteArgs } from '@syncfusion/ej2-grids';
8
- import { BatchAddArgs, BeforeBatchAddArgs } from '@syncfusion/ej2-grids';
9
- import { updateParentRow, editAction } from './crud-actions';
10
- import { FocusStrategy } from '@syncfusion/ej2-grids/src/grid/services/focus-strategy';
11
- import { classList } from '@syncfusion/ej2-base';
12
- import { RowPosition } from '../enum';
13
-
14
- /**
15
- * `BatchEdit` module is used to handle batch editing actions.
16
- *
17
- * @hidden
18
- */
19
- export class BatchEdit {
20
- private parent: TreeGrid;
21
- private isSelfReference: boolean;
22
- private addRowRecord: ITreeData;
23
- private batchChildCount: number = 0;
24
- private addedRecords: string = 'addedRecords';
25
- private deletedRecords: string = 'deletedRecords';
26
- private matrix: Object[];
27
- private batchRecords: Object[];
28
- private currentViewRecords: Object[];
29
- private batchAddedRecords: Object[] = [];
30
- private batchDeletedRecords: Object[] = [];
31
- private batchIndex: number;
32
- private batchAddRowRecord: Object[] = [];
33
- private isAdd: boolean;
34
- private newBatchRowAdded: boolean;
35
- private selectedIndex: number;
36
- private addRowIndex: number;
37
-
38
- constructor(parent: TreeGrid) {
39
- this.parent = parent;
40
- this.isSelfReference = !isNullOrUndefined(parent.parentIdMapping);
41
- this.batchRecords = [];
42
- this.currentViewRecords = [];
43
- this.isAdd = false;
44
- this.addEventListener();
45
- }
46
-
47
- public addEventListener(): void {
48
- this.parent.on(events.cellSaved, this.cellSaved, this);
49
- this.parent.on(events.batchAdd, this.batchAdd, this);
50
- this.parent.on(events.beforeBatchAdd, this.beforeBatchAdd, this);
51
- this.parent.on(events.batchSave, this.batchSave, this);
52
- this.parent.on(events.beforeBatchDelete, this.beforeBatchDelete, this);
53
- this.parent.on(events.beforeBatchSave, this.beforeBatchSave, this);
54
- this.parent.on('batchPageAction', this.batchPageAction, this);
55
- this.parent.on('batchCancelAction', this.batchCancelAction, this);
56
- this.parent.grid.on('immutable-batch-cancel', this.immutableBatchAction, this);
57
- this.parent.grid.on('next-cell-index', this.nextCellIndex, this);
58
- }
59
- /**
60
- * @hidden
61
- * @returns {void}
62
- */
63
- public removeEventListener(): void {
64
- if (this.parent.isDestroyed) { return; }
65
- this.parent.off(events.cellSaved, this.cellSaved);
66
- this.parent.off(events.batchAdd, this.batchAdd);
67
- this.parent.off(events.batchSave, this.batchSave);
68
- this.parent.off(events.beforeBatchAdd, this.beforeBatchAdd);
69
- this.parent.off(events.beforeBatchDelete, this.beforeBatchDelete);
70
- this.parent.off(events.beforeBatchSave, this.beforeBatchSave);
71
- this.parent.off('batchPageAction', this.batchPageAction);
72
- this.parent.off('batchCancelAction', this.batchCancelAction);
73
- this.parent.grid.off('immutable-batch-cancel', this.immutableBatchAction);
74
- this.parent.grid.off('next-cell-index', this.nextCellIndex);
75
- }
76
- /**
77
- * To destroy the editModule
78
- *
79
- * @returns {void}
80
- * @hidden
81
- */
82
- public destroy(): void {
83
- this.removeEventListener();
84
- }
85
- /**
86
- * @hidden
87
- * @returns {Object[]} Returns modified records in batch editing.
88
- */
89
- public getBatchRecords(): Object[] {
90
- return this.batchRecords;
91
- }
92
- /**
93
- * @hidden
94
- * @returns {number} Returns index of newly add row
95
- */
96
- public getAddRowIndex(): number {
97
- return this.addRowIndex;
98
- }
99
- /**
100
- * @hidden
101
- * @returns {number} Returns selected row index
102
- */
103
- public getSelectedIndex(): number {
104
- return this.selectedIndex;
105
- }
106
- /**
107
- * @hidden
108
- * @returns {number} Returns newly added child count
109
- */
110
- public getBatchChildCount(): number {
111
- return this.batchChildCount;
112
- }
113
- private batchPageAction(): void {
114
- const data: Object[] = <Object[]>(this.parent.grid.dataSource instanceof DataManager ?
115
- this.parent.grid.dataSource.dataSource.json : this.parent.grid.dataSource);
116
- const primaryKey: string = this.parent.grid.getPrimaryKeyFieldNames()[0];
117
- let index: number;
118
- if (!isNullOrUndefined(this.batchAddedRecords) && this.batchAddedRecords.length) {
119
- for (let i: number = 0; i < this.batchAddedRecords.length; i++) {
120
- index = data.map((e: Object) => { return e[`${primaryKey}`]; }).indexOf(this.batchAddedRecords[parseInt(i.toString(), 10)][`${primaryKey}`]);
121
- data.splice(index, 1);
122
- }
123
- }
124
- this.batchAddedRecords = this.batchRecords = this.batchAddRowRecord = this.batchDeletedRecords = this.currentViewRecords = [];
125
- }
126
- private cellSaved(args: CellSaveArgs): void {
127
- const actualCellIndex: number = args.column.index;
128
- if (actualCellIndex === this.parent.treeColumnIndex) {
129
- this.parent.renderModule.cellRender({ data: args.rowData, cell: args.cell,
130
- column: this.parent.grid.getColumnByIndex(args.column.index)
131
- });
132
- }
133
- if (this.isAdd && this.parent.editSettings.mode === 'Batch' && this.parent.editSettings.newRowPosition !== 'Bottom') {
134
- const data: Object[] = <Object[]>(this.parent.grid.dataSource instanceof DataManager ?
135
- this.parent.grid.dataSource.dataSource.json : this.parent.grid.dataSource);
136
- let added: ITreeData; const level: string = 'level';
137
- const primaryKey: string = this.parent.grid.getPrimaryKeyFieldNames()[0]; let currentDataIndex: number;
138
- let indexvalue: number;
139
- const parentItem: string = 'parentItem'; const uniqueID: string = 'uniqueID';
140
- const parentRecord: ITreeData = this.selectedIndex > -1 ? this.batchRecords[parseInt(this.addRowIndex.toString(), 10)][`${parentItem}`] : null;
141
- let idMapping: Object; let parentUniqueID: string; let parentIdMapping: string;
142
- let rowObjectIndex: number = this.parent.editSettings.newRowPosition === 'Top' || this.selectedIndex === -1 ? 0 :
143
- this.parent.editSettings.newRowPosition === 'Above' ? this.addRowIndex
144
- : this.addRowIndex + 1;
145
- rowObjectIndex = this.getActualRowObjectIndex(rowObjectIndex);
146
- if (this.newBatchRowAdded) {
147
- if (this.batchRecords.length) {
148
- idMapping = this.batchRecords[this.addRowIndex][this.parent.idMapping];
149
- parentIdMapping = this.batchRecords[this.addRowIndex][this.parent.parentIdMapping];
150
- if (this.batchRecords[parseInt(this.addRowIndex.toString(), 10)][`${parentItem}`]) {
151
- parentUniqueID = this.batchRecords[parseInt(this.addRowIndex.toString(), 10)][`${parentItem}`][`${uniqueID}`];
152
- }
153
- }
154
- this.batchAddedRecords = extendArray(this.batchAddedRecords);
155
- this.batchAddRowRecord = extendArray(this.batchAddRowRecord);
156
- this.batchAddRowRecord.push(this.batchRecords[this.addRowIndex]);
157
- added = this.parent.grid.getRowsObject()[parseInt(rowObjectIndex.toString(), 10)].changes;
158
- added.uniqueID = getUid(this.parent.element.id + '_data_');
159
- setValue('uniqueIDCollection.' + added.uniqueID , added, this.parent);
160
- if (!Object.prototype.hasOwnProperty.call(added, 'level')) {
161
- this.batchIndex = this.selectedIndex === -1 ? 0 : this.batchIndex;
162
- if (this.parent.editSettings.newRowPosition === 'Child') {
163
- added.primaryParent = parentRecord;
164
- if (this.selectedIndex > -1) {
165
- added.parentItem = extend({}, this.batchRecords[this.addRowIndex]);
166
- added.parentUniqueID = added.parentItem.uniqueID;
167
- delete added.parentItem.childRecords; delete added.parentItem[this.parent.childMapping];
168
- added.level = added.parentItem.level + 1; added.index = this.batchIndex;
169
- const childRecordCount: number = findChildrenRecords(this.batchRecords[this.addRowIndex]).length;
170
- let record: ITreeData = findChildrenRecords(this.batchRecords[this.addRowIndex])[childRecordCount - 1];
171
- record = isNullOrUndefined(record) ? this.batchRecords[this.addRowIndex] : record;
172
- currentDataIndex = data.map((e: Object) => { return e[`${primaryKey}`]; }).indexOf(record[`${primaryKey}`]);
173
- if (this.isSelfReference) {
174
- added[this.parent.parentIdMapping] = idMapping;
175
- }
176
- updateParentRow(primaryKey, added.parentItem, 'add', this.parent, this.isSelfReference, added);
177
- }
178
- } else if ((this.parent.editSettings.newRowPosition === 'Above' || this.parent.editSettings.newRowPosition === 'Below')
179
- && !isNullOrUndefined(this.batchRecords[this.addRowIndex])) {
180
- added.level = this.batchRecords[parseInt(this.addRowIndex.toString(), 10)][`${level}`];
181
- if (added.level && this.selectedIndex > -1) {
182
- added.parentItem = parentRecord; added.parentUniqueID = parentUniqueID;
183
- delete added.parentItem.childRecords; delete added.parentItem[this.parent.childMapping];
184
- }
185
- added.index = this.parent.editSettings.newRowPosition === 'Below' ? this.batchIndex : this.batchIndex - 1;
186
- if (this.parent.editSettings.newRowPosition === 'Below' && this.selectedIndex > -1) {
187
- const childRecordCount: number = findChildrenRecords(this.batchRecords[this.addRowIndex]).length;
188
- let record: ITreeData = findChildrenRecords(this.batchRecords[this.addRowIndex])[childRecordCount - 1];
189
- record = isNullOrUndefined(record) ? this.batchRecords[this.addRowIndex] : record;
190
- currentDataIndex = data.map((e: Object) => { return e[`${primaryKey}`]; }).indexOf(record[`${primaryKey}`]);
191
- }
192
- if (this.parent.editSettings.newRowPosition === 'Above' && this.selectedIndex > -1) {
193
- const record: ITreeData = this.batchRecords[this.addRowIndex];
194
- currentDataIndex = data.map((e: Object) => { return e[`${primaryKey}`]; }).indexOf(record[`${primaryKey}`]);
195
- }
196
- if (this.isSelfReference) {
197
- added[this.parent.parentIdMapping] = parentIdMapping;
198
- }
199
- }
200
- added.index = added.index === -1 ? 0 : added.index;
201
- added.hasChildRecords = false; added.childRecords = [];
202
- this.batchRecords.splice(added.index, 0, added);
203
- this.currentViewRecords.splice(added.index, 0, added);
204
- if (currentDataIndex) {
205
- indexvalue = currentDataIndex;
206
- } else { indexvalue = added.index; }
207
- if (this.parent.editSettings.newRowPosition !== 'Above') {
208
- indexvalue = added.index === 0 ? indexvalue : indexvalue + 1;
209
- }
210
- data.splice(indexvalue, 0, added);
211
- this.batchAddedRecords.push(added);
212
- }
213
- this.parent.grid.getRowsObject()[parseInt(rowObjectIndex.toString(), 10)].data = added;
214
- this.newBatchRowAdded = false;
215
- }
216
- }
217
- }
218
-
219
- private beforeBatchAdd(e: BeforeBatchAddArgs): void {
220
- const isTabLastRow: string = 'isTabLastRow';
221
- if (this.parent.editSettings.mode === 'Cell' && this.parent.editModule[`${isTabLastRow}`]) {
222
- e.cancel = true;
223
- this.parent.editModule[`${isTabLastRow}`] = false;
224
- return;
225
- }
226
- if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex']) &&
227
- !this.parent.editModule['isAddedRowByContextMenu'] && (this.parent.grid.selectedRowIndex === -1 || this.parent.editModule['batchEditModule'].isAdd)) {
228
- this.selectedIndex = this.parent.editModule['selectedIndex'];
229
- this.addRowIndex = this.parent.editModule['addRowIndex'];
230
- this.addRowRecord = this.batchRecords.length ? this.batchRecords[this.selectedIndex]
231
- : this.parent.getCurrentViewRecords()[this.selectedIndex];
232
- }
233
- else {
234
- this.selectedIndex = this.parent.grid.selectedRowIndex;
235
- this.addRowIndex = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
236
- this.parent.editModule['addRowIndex'] = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
237
- this.addRowRecord = this.parent.getSelectedRecords()[0];
238
- }
239
- }
240
-
241
- private batchAdd(e: BatchAddArgs): void {
242
- if (this.parent.editSettings.newRowPosition !== 'Bottom') {
243
- this.isAdd = true; this.newBatchRowAdded = true; let actualIndex: number = 0;
244
- if (!this.batchRecords.length) {
245
- this.batchAddedRecords = [];
246
- this.batchRecords = extendArray(this.parent.grid.getCurrentViewRecords());
247
- this.currentViewRecords = extendArray(this.parent.grid.getCurrentViewRecords());
248
- }
249
- if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex'])) {
250
- classList(this.parent.grid.getDataRows()[0], ['e-batchrow'], []);
251
- }
252
- if (this.parent.editSettings.newRowPosition !== 'Top') {
253
- let records: Object[] = this.parent.grid.getCurrentViewRecords();
254
- if (this.parent.editSettings.mode === 'Batch' && (this.parent.getBatchChanges()[this.addedRecords].length > 1
255
- || this.parent.getBatchChanges()[this.deletedRecords].length)) {
256
- records = this.batchRecords;
257
- }
258
- this.updateChildCount(records);
259
- this.parent.notify(events.beginAdd, {});
260
- this.batchChildCount = 0;
261
- }
262
- this.updateRowIndex();
263
- // update focus module, need to refix this once grid source modified.
264
- const focusModule: FocusStrategy = getValue('focusModule', this.parent.grid);
265
- const table: Element = this.parent.getContentTable();
266
- if (this.parent.getBatchChanges()[this.deletedRecords].length && this.parent.editSettings.newRowPosition === 'Above') {
267
- actualIndex = (e.row as HTMLTableRowElement).rowIndex;
268
- focusModule.getContent().matrix.matrix = this.matrix as number[][];
269
- } else {
270
- actualIndex = (table.getElementsByClassName('e-batchrow')[0] as HTMLTableRowElement).rowIndex;
271
- // if (this.parent.frozenRows || this.parent.frozenColumns) {
272
- // actualIndex = this.batchIndex;
273
- // }
274
- }
275
- focusModule.getContent().matrix.current = [actualIndex, focusModule.getContent().matrix.current[1]];
276
- if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex']) && !this.parent.editModule['isAddedRowByContextMenu']) {
277
- const newlyAddedRecords: ITreeData[] = this.parent.getBatchChanges()['addedRecords'];
278
- const index: number = parseInt(this.parent.getContentTable().getElementsByClassName('e-insertedrow')[newlyAddedRecords.length - 1].getAttribute('data-rowindex'), 10);
279
- this.batchRecords.splice(index, 0, newlyAddedRecords[newlyAddedRecords.length - 1]);
280
- }
281
- }
282
- }
283
- private beforeBatchDelete(args?: BeforeBatchDeleteArgs): void {
284
- if (!this.batchRecords.length) {
285
- this.batchRecords = extendArray(this.parent.grid.getCurrentViewRecords());
286
- this.currentViewRecords = extendArray(this.parent.grid.getCurrentViewRecords());
287
- }
288
- const focusModule: FocusStrategy = getValue('focusModule', this.parent.grid);
289
- this.matrix = focusModule.getContent().matrix.matrix;
290
- const row: Element[] = []; let records: ITreeData[] = [];
291
- const primarykey: string = this.parent.grid.getPrimaryKeyFieldNames()[0];
292
- let data: ITreeData;
293
- let childs: ITreeData[];
294
- let uid: string;
295
- if (!isNullOrUndefined(args.row) && this.parent.getSelectedRows().indexOf(args.row as Element) === -1) {
296
- data = args.rowData;
297
- childs = findChildrenRecords(data);
298
- uid = (args.row as Element).getAttribute('data-uid');
299
- }
300
- else {
301
- data = this.parent.grid.getSelectedRecords()[this.parent.grid.getSelectedRecords().length - 1];
302
- childs = findChildrenRecords(data);
303
- uid = this.parent.getSelectedRows()[0].getAttribute('data-uid');
304
- }
305
- const parentRowIndex: number = parseInt(this.parent.grid.getRowElementByUID(uid).getAttribute('data-rowindex'), 10);
306
- if (childs.length){
307
- const totalCount: number = parentRowIndex + childs.length; const firstChildIndex: number = parentRowIndex + 1;
308
- for (let i: number = firstChildIndex; i <= totalCount; i++){
309
- row.push(this.parent.grid.getDataRows()[parseInt(i.toString(), 10)] as Element);
310
- if (this.parent.frozenRows || this.parent.frozenColumns || this.parent.getFrozenColumns()) {
311
- row.push(this.parent.grid.getHeaderContent()[parseInt(i.toString(), 10)] as Element);
312
- }
313
- }
314
- }
315
- if (!isNullOrUndefined(data.parentItem)) {
316
- const parentItem: ITreeData = getParentData(this.parent, data.parentItem.uniqueID);
317
- if (!isNullOrUndefined(parentItem) && parentItem.hasChildRecords) {
318
- const childIndex: number = parentItem.childRecords.indexOf(data);
319
- parentItem.childRecords.splice(childIndex, 1);
320
- }
321
- this.batchDeletedRecords = extendArray(this.batchDeletedRecords);
322
- this.batchDeletedRecords.push(data);
323
- }
324
- childs.push(data);
325
- records = childs;
326
- for (let i: number = 0; i < records.length; i++) {
327
- const indexvalue: number = this.batchRecords.map((e: Object) => { return e[`${primarykey}`]; }).indexOf(records[parseInt(i.toString(), 10)][`${primarykey}`]);
328
- if (indexvalue !== -1) {
329
- this.batchRecords.splice(indexvalue , 1);
330
- }
331
- }
332
- for (let i: number = 0; i < row.length; i++) {
333
- if (!isNullOrUndefined(row[parseInt(i.toString(), 10)])) {
334
- this.parent.grid.selectionModule.selectedRecords.push(row[parseInt(i.toString(), 10)]);
335
- }
336
- }
337
- }
338
- private updateRowIndex(): void {
339
- const rows: Element[] = this.parent.grid.getDataRows();
340
- for (let i: number = 0 ; i < rows.length; i++) {
341
- rows[parseInt(i.toString(), 10)].setAttribute('data-rowindex', i.toString());
342
- }
343
- }
344
- private updateChildCount(records: Object[]): void {
345
- const primaryKey: string = this.parent.grid.getPrimaryKeyFieldNames()[0];
346
- const addedRecords: string = 'addedRecords';
347
- const parentItem: string = this.parent.editSettings.newRowPosition === 'Child' ? 'primaryParent' : 'parentItem';
348
- for (let i: number = 0; i < this.parent.getBatchChanges()[`${addedRecords}`].length; i++ ) {
349
- if (!isNullOrUndefined(this.parent.getBatchChanges()[`${addedRecords}`][parseInt(i.toString(), 10)][`${parentItem}`])) {
350
- if (this.parent.getBatchChanges()[`${addedRecords}`][parseInt(i.toString(), 10)][`${parentItem}`][`${primaryKey}`] === records[parseInt(this.addRowIndex.toString(), 10)][`${primaryKey}`]) {
351
- this.batchChildCount = this.batchChildCount + 1;
352
- }
353
- }
354
- }
355
- }
356
-
357
- private beforeBatchSave(e: BeforeBatchSaveArgs): void {
358
- const changeRecords: string = 'changedRecords'; const deleterecords: string = 'deletedRecords';
359
- const changedRecords: ITreeData[] = e.batchChanges[`${changeRecords}`];
360
- if (e.batchChanges[`${changeRecords}`].length) {
361
- let columnName: string;
362
- for (let i: number = 0; i < changedRecords.length; i++) {
363
- editAction({ value: <ITreeData>changedRecords[parseInt(i.toString(), 10)], action: 'edit' }, this.parent,
364
- this.isSelfReference, this.addRowIndex, this.selectedIndex, columnName);
365
- }
366
- }
367
- if (e.batchChanges[`${deleterecords}`].length) {
368
- const deletedRecords: ITreeData[] = e.batchChanges[`${deleterecords}`];
369
- const record: ITreeData[] = deletedRecords;
370
- for (let i: number = 0; i < record.length; i++) {
371
- this.deleteUniqueID(record[parseInt(i.toString(), 10)].uniqueID);
372
- const childs: ITreeData[] = findChildrenRecords(record[parseInt(i.toString(), 10)]);
373
- for (let c: number = 0; c < childs.length; c++) {
374
- this.deleteUniqueID(childs[parseInt(c.toString(), 10)].uniqueID);
375
- }
376
- e.batchChanges[`${deleterecords}`] = [...e.batchChanges[`${deleterecords}`], ...childs];
377
- }
378
- }
379
- this.isAdd = false;
380
- }
381
- private deleteUniqueID( value: string) : void {
382
- const idFilter: string = 'uniqueIDFilterCollection';
383
- delete this.parent[`${idFilter}`][`${value}`];
384
- const id: string = 'uniqueIDCollection';
385
- delete this.parent[`${id}`][`${value}`];
386
- }
387
-
388
- private batchCancelAction() : void {
389
- const targetElement: string = 'targetElement'; let index: number; const parentItem: string = 'parentItem';
390
- const indexvalue: string = 'index';
391
- const currentViewRecords: Object[] = this.parent.grid.getCurrentViewRecords(); const childRecords: string = 'childRecords';
392
- const data: Object[] = <Object[]>(this.parent.grid.dataSource instanceof DataManager ?
393
- this.parent.grid.dataSource.dataSource.json : this.parent.grid.dataSource);
394
- const primaryKey: string = this.parent.grid.getPrimaryKeyFieldNames()[0];
395
- if (!isNullOrUndefined(this.batchAddedRecords)) {
396
- for (let i: number = 0; i < this.batchAddedRecords.length; i++) {
397
- index = data.map((e: Object) => { return e[`${primaryKey}`]; }).indexOf(this.batchAddedRecords[parseInt(i.toString(), 10)][`${primaryKey}`]);
398
- if (index !== -1) {
399
- data.splice(index, 1);
400
- }
401
- if (this.parent.editSettings.newRowPosition === 'Child') {
402
- index = currentViewRecords.map((e: Object) => { return e[`${primaryKey}`]; })
403
- .indexOf(this.batchAddedRecords[parseInt(i.toString(), 10)][`${parentItem}`] ? this.batchAddedRecords[parseInt(i.toString(), 10)][`${parentItem}`][`${primaryKey}`]
404
- : this.batchAddedRecords[parseInt(i.toString(), 10)][`${primaryKey}`]);
405
- if (!isNullOrUndefined(currentViewRecords[parseInt(index.toString(), 10)])) {
406
- const children: Object[] = currentViewRecords[parseInt(index.toString(), 10)][`${childRecords}`];
407
- for (let j: number = 0; children && j < children.length; j++) {
408
- if (children[parseInt(j.toString(), 10)][`${primaryKey}`] === this.batchAddedRecords[parseInt(i.toString(), 10)][`${primaryKey}`]) {
409
- currentViewRecords[parseInt(index.toString(), 10)][`${childRecords}`].splice(j, 1);
410
- }
411
- }
412
- }
413
- }
414
- }
415
- }
416
- if (!isNullOrUndefined(this.parent[`${targetElement}`])) {
417
- const row: HTMLTableRowElement = this.parent[`${targetElement}`].closest('tr');
418
- this.parent.collapseRow(row);
419
- this.parent[`${targetElement}`] = null;
420
- }
421
- if (!isNullOrUndefined(this.batchDeletedRecords)) {
422
- for (let i: number = 0; i < this.batchDeletedRecords.length; i++) {
423
- if (!isNullOrUndefined(this.batchDeletedRecords[parseInt(i.toString(), 10)][`${parentItem}`])) {
424
- index = currentViewRecords.map((e: Object) => { return e[`${primaryKey}`]; })
425
- .indexOf(this.batchDeletedRecords[parseInt(i.toString(), 10)][`${parentItem}`][`${primaryKey}`]);
426
- const positionIndex: number = this.batchDeletedRecords[parseInt(i.toString(), 10)][`${indexvalue}`] === 0 ? this.batchDeletedRecords[parseInt(i.toString(), 10)][`${indexvalue}`] :
427
- this.batchDeletedRecords[parseInt(i.toString(), 10)][`${indexvalue}`] - 1;
428
- if (!isNullOrUndefined(currentViewRecords[parseInt(index.toString(), 10)])) {
429
- currentViewRecords[parseInt(index.toString(), 10)][`${childRecords}`].splice(positionIndex, 0, this.batchDeletedRecords[parseInt(i.toString(), 10)]);
430
- }
431
- }
432
- }
433
- }
434
- this.batchAddedRecords = this.batchRecords = this.batchAddRowRecord = this.currentViewRecords = [];
435
- this.batchRecords = extendArray(this.parent.grid.getCurrentViewRecords()); this.batchIndex = 0;
436
- this.currentViewRecords = extendArray(this.parent.grid.getCurrentViewRecords());
437
- this.batchDeletedRecords = [];
438
- this.parent.grid.renderModule.refresh();
439
- }
440
-
441
- private batchSave(args: { updatedRecords: BatchChanges, index: number }) : void {
442
- if (this.parent.editSettings.mode === 'Batch') {
443
- let i: number; const batchChanges: Object = Object.hasOwnProperty.call(args, 'updatedRecords') ? args.updatedRecords : this.parent.getBatchChanges(); const deletedRecords: string = 'deletedRecords';
444
- const addedRecords: string = 'addedRecords'; const index: string = 'index'; const uniqueID: string = 'uniqueID';
445
- const data: Object[] = <Object[]>(this.parent.grid.dataSource instanceof DataManager ?
446
- this.parent.grid.dataSource.dataSource.json : this.parent.grid.dataSource);
447
- let currentViewRecords: Object[] = this.parent.grid.getCurrentViewRecords();
448
- const primarykey: string = this.parent.grid.getPrimaryKeyFieldNames()[0]; const level: string = 'level';
449
- const addRecords: ITreeData[] = batchChanges[`${addedRecords}`]; const parentItem: string = 'parentItem';
450
- let selectedIndex: number; let addRowIndex: number; let columnName: string;
451
- let addRowRecord: ITreeData; const childRecords: string = 'childRecords';
452
- if (addRecords.length > 1 && this.parent.editSettings.newRowPosition !== 'Bottom') {
453
- addRecords.reverse();
454
- }
455
- if (this.parent.editSettings.newRowPosition !== 'Bottom' && !Object.hasOwnProperty.call(args, 'updatedRecords')) {
456
- data.splice(data.length - addRecords.length, addRecords.length);
457
- if (this.parent.editModule['isAddedRowByMethod'] && addRecords.length && !isNullOrUndefined(this.parent.editModule['addRowIndex']) && !this.parent.editModule['isAddedRowByContextMenu']) {
458
- addRecords.reverse();
459
- for (let i: number = 0; i < addRecords.length; i++) {
460
- const index: number = parseInt(this.parent.getContentTable().getElementsByClassName('e-insertedrow')[parseInt(i.toString(), 10)].getAttribute('data-rowindex'), 10);
461
- data.splice(index, 0, addRecords[parseInt(i.toString(), 10)]);
462
- }
463
- }
464
- if (!this.parent.allowPaging && data.length !== currentViewRecords.length) {
465
- if (currentViewRecords.length > addRecords.length) {
466
- currentViewRecords.splice(currentViewRecords.length - addRecords.length, addRecords.length);
467
- }
468
- } else {
469
- const totalRecords: Object[] = extendArray(data);
470
- if (totalRecords.length) {
471
- const startIndex: number = totalRecords.map((e: Object) => { return e[`${primarykey}`]; })
472
- .indexOf(currentViewRecords[0][`${primarykey}`]);
473
- const endIndex: number = startIndex + this.parent.grid.pageSettings.pageSize;
474
- currentViewRecords = totalRecords.splice(startIndex, endIndex);
475
- }
476
- }
477
- }
478
- if (this.batchAddRowRecord.length === 0) { this.batchAddRowRecord.push(this.parent.flatData[args.index]); }
479
- if (this.parent.editModule['isAddedRowByContextMenu']) {
480
- addRecords.reverse();
481
- }
482
- for (i = 0; i < addRecords.length; i++) {
483
- const taskData: ITreeData = extend({}, addRecords[parseInt(i.toString(), 10)]);
484
- delete taskData.parentItem; delete taskData.uniqueID; delete taskData.index; delete taskData.level;
485
- delete taskData.hasChildRecords; delete taskData.childRecords; delete taskData.parentUniqueID;
486
- if (!isNullOrUndefined(taskData.primaryParent)) {
487
- delete taskData.primaryParent;
488
- }
489
- if (addRecords.length > 1 && this.parent.editModule['isAddedRowByContextMenu']) {
490
- const rowPosition: RowPosition = this.parent.editSettings.newRowPosition;
491
- this.parent.editSettings.newRowPosition = this.parent.editModule['previousNewRowPosition'];
492
- this.parent.editModule['previousNewRowPosition'] = rowPosition;
493
- }
494
- addRecords[parseInt(i.toString(), 10)].taskData = taskData;
495
- addRowRecord = this.batchAddRowRecord[parseInt(i.toString(), 10)];
496
- if (isNullOrUndefined(addRowRecord)) {
497
- addRowRecord = this.batchAddRowRecord[i - 1];
498
- }
499
- if (this.isSelfReference) {
500
- if (!isNullOrUndefined(addRecords[parseInt(i.toString(), 10)].parentItem)) {
501
- updateParentRow(primarykey, addRecords[parseInt(i.toString(), 10)].parentItem, 'add', this.parent, this.isSelfReference, addRecords[parseInt(i.toString(), 10)]);
502
- }
503
- }
504
- if (!isNullOrUndefined(addRowRecord)) {
505
- addRowIndex = addRowRecord.index;
506
- }
507
- if (this.parent.editSettings.newRowPosition !== 'Top' && this.parent.editSettings.newRowPosition !== 'Bottom') {
508
- if (isNullOrUndefined(addRecords[parseInt(i.toString(), 10)].parentItem) && this.selectedIndex === -1) {
509
- selectedIndex = -1;
510
- addRowRecord = null;
511
- }
512
- }
513
- editAction({ value: addRecords[parseInt(i.toString(), 10)], action: 'add' }, this.parent,
514
- this.isSelfReference, addRowIndex, selectedIndex, columnName, addRowRecord);
515
- selectedIndex = null;
516
- if (this.parent.editSettings.newRowPosition === 'Child' && !isNullOrUndefined(addRecords[parseInt(i.toString(), 10)][`${parentItem}`]) &&
517
- (isNullOrUndefined(this.parent.editModule['addRowIndex']) || this.isSelfReference)) {
518
- const indexValue: number = currentViewRecords.map((e: Object) => { return e[`${primarykey}`]; })
519
- .indexOf(addRecords[parseInt(i.toString(), 10)][`${parentItem}`][`${primarykey}`]);
520
- const children: Object[] = currentViewRecords[parseInt(indexValue.toString(), 10)][`${childRecords}`];
521
- for (let j: number = 0; j < children.length; j++) {
522
- if (children[parseInt(j.toString(), 10)][`${primarykey}`] === addRecords[parseInt(i.toString(), 10)][`${primarykey}`]) {
523
- currentViewRecords[parseInt(indexValue.toString(), 10)][`${childRecords}`].splice(j, 1);
524
- }
525
- }
526
- }
527
- }
528
- if (batchChanges[`${deletedRecords}`].length) {
529
- for (i = 0; i < batchChanges[`${deletedRecords}`].length; i++) {
530
- editAction({ value: batchChanges[`${deletedRecords}`][parseInt(i.toString(), 10)], action: 'delete' }, this.parent,
531
- this.isSelfReference, addRowIndex, selectedIndex, columnName, addRowRecord);
532
- }
533
- }
534
- this.parent.parentData = [];
535
- for (let i: number = 0; i < data.length; i++) {
536
- data[parseInt(i.toString(), 10)][`${index}`] = i;
537
- setValue('uniqueIDCollection.' + data[parseInt(i.toString(), 10)][`${uniqueID}`] + '.index', i, this.parent);
538
- if (!data[parseInt(i.toString(), 10)][`${level}`]) {
539
- this.parent.parentData.push(data[parseInt(i.toString(), 10)]);
540
- }
541
- }
542
- }
543
- this.batchAddRowRecord = this.batchAddedRecords = this.batchRecords = this.batchDeletedRecords = this.currentViewRecords = [];
544
- if (this.parent.editModule['isAddedRowByContextMenu']) {
545
- this.parent.editModule['isAddedRowByContextMenu'] = false;
546
- }
547
- }
548
-
549
- private getActualRowObjectIndex(index: number): number {
550
- const rows: Element[] = this.parent.grid.getDataRows();
551
- if ((this.parent.editSettings.newRowPosition === 'Below' || this.parent.editSettings.newRowPosition === 'Child')
552
- && this.selectedIndex > -1) {
553
- if (!isNullOrUndefined(this.batchRecords[this.addRowIndex]) && (this.batchRecords[this.addRowIndex] as ITreeData).expanded) {
554
- if (this.parent.getBatchChanges()[this.addedRecords].length > 1
555
- || this.parent.getBatchChanges()[this.deletedRecords].length) {
556
- index += findChildrenRecords(this.batchRecords[this.addRowIndex]).length;
557
- if (this.parent.editSettings.newRowPosition !== 'Child') {
558
- const batchChildCount: number = this.getBatchChildCount();
559
- index = index + batchChildCount;
560
- }
561
- } else {
562
- index += findChildrenRecords(this.batchRecords[this.addRowIndex]).length;
563
- }
564
- }
565
- if (index >= rows.length) {
566
- index = rows.length - 1;
567
- }
568
- this.updateChildCount(this.parent.grid.getCurrentViewRecords());
569
- if (this.batchChildCount) {
570
- index += this.batchChildCount;
571
- }
572
- this.batchChildCount = 0;
573
- }
574
- return index;
575
- }
576
-
577
- private immutableBatchAction(e: { rows: Row<Column>[], args?: NotifyArgs }): void {
578
- e.args.cancel = true;
579
- const changes: Object = this.parent.grid.getBatchChanges();
580
- let addedRecords: Object[] = []; const index: string = 'index';
581
- if (Object.keys(changes).length) {
582
- addedRecords = (<{ addedRecords?: Object[] }>changes).addedRecords;
583
- }
584
- for (let i: number = 0; i < addedRecords.length; i++) {
585
- e.rows.splice(addedRecords[parseInt(i.toString(), 10)][`${index}`], 1);
586
- }
587
- }
588
-
589
- private nextCellIndex(args: NotifyArgs): void {
590
- const index: string = 'index'; const rowIndex: string = 'rowIndex';
591
- if (this.parent.getSelectedRows().length) {
592
- args[`${index}`] = this.parent.getSelectedRows()[0][`${rowIndex}`];
593
- }
594
- else {
595
- args[`${index}`] = this.batchIndex;
596
- }
597
- }
598
-
599
- }
600
-
601
-
602
-
1
+ import { TreeGrid } from '../base';
2
+ /**
3
+ * `BatchEdit` module is used to handle batch editing actions.
4
+ *
5
+ * @hidden
6
+ */
7
+ export declare class BatchEdit {
8
+ private parent;
9
+ private isSelfReference;
10
+ private addRowRecord;
11
+ private batchChildCount;
12
+ private addedRecords;
13
+ private deletedRecords;
14
+ private matrix;
15
+ private batchRecords;
16
+ private currentViewRecords;
17
+ private batchAddedRecords;
18
+ private batchDeletedRecords;
19
+ private batchIndex;
20
+ private batchAddRowRecord;
21
+ private isAdd;
22
+ private newBatchRowAdded;
23
+ private selectedIndex;
24
+ private addRowIndex;
25
+ constructor(parent: TreeGrid);
26
+ addEventListener(): void;
27
+ /**
28
+ * @hidden
29
+ * @returns {void}
30
+ */
31
+ removeEventListener(): void;
32
+ /**
33
+ * To destroy the editModule
34
+ *
35
+ * @returns {void}
36
+ * @hidden
37
+ */
38
+ destroy(): void;
39
+ /**
40
+ * @hidden
41
+ * @returns {Object[]} Returns modified records in batch editing.
42
+ */
43
+ getBatchRecords(): Object[];
44
+ /**
45
+ * @hidden
46
+ * @returns {number} Returns index of newly add row
47
+ */
48
+ getAddRowIndex(): number;
49
+ /**
50
+ * @hidden
51
+ * @returns {number} Returns selected row index
52
+ */
53
+ getSelectedIndex(): number;
54
+ /**
55
+ * @hidden
56
+ * @returns {number} Returns newly added child count
57
+ */
58
+ getBatchChildCount(): number;
59
+ private batchPageAction;
60
+ private cellSaved;
61
+ private beforeBatchAdd;
62
+ private batchAdd;
63
+ private beforeBatchDelete;
64
+ private updateRowIndex;
65
+ private updateChildCount;
66
+ private beforeBatchSave;
67
+ private deleteUniqueID;
68
+ private batchCancelAction;
69
+ private batchSave;
70
+ private getActualRowObjectIndex;
71
+ private immutableBatchAction;
72
+ private nextCellIndex;
73
+ }