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