@syncfusion/ej2-treegrid 30.1.38 → 31.1.17
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/aceconfig.js +17 -0
- 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 +265 -159
- package/dist/es6/ej2-treegrid.es2015.js.map +1 -1
- package/dist/es6/ej2-treegrid.es5.js +293 -169
- 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/dist/ts/index.d.ts +4 -0
- package/dist/ts/index.ts +4 -0
- package/dist/ts/treegrid/actions/batch-edit.d.ts +74 -0
- package/dist/ts/treegrid/actions/batch-edit.ts +627 -0
- package/dist/ts/treegrid/actions/clipboard.d.ts +36 -0
- package/dist/ts/treegrid/actions/clipboard.ts +174 -0
- package/dist/ts/treegrid/actions/column-chooser.d.ts +37 -0
- package/dist/ts/treegrid/actions/column-chooser.ts +55 -0
- package/dist/ts/treegrid/actions/column-menu.d.ts +24 -0
- package/dist/ts/treegrid/actions/column-menu.ts +39 -0
- package/dist/ts/treegrid/actions/command-column.d.ts +24 -0
- package/dist/ts/treegrid/actions/command-column.ts +32 -0
- package/dist/ts/treegrid/actions/context-menu.d.ts +42 -0
- package/dist/ts/treegrid/actions/context-menu.ts +149 -0
- package/dist/ts/treegrid/actions/crud-actions.d.ts +66 -0
- package/dist/ts/treegrid/actions/crud-actions.ts +388 -0
- package/dist/ts/treegrid/actions/detail-row.d.ts +39 -0
- package/dist/ts/treegrid/actions/detail-row.ts +124 -0
- package/dist/ts/treegrid/actions/edit.d.ts +121 -0
- package/dist/ts/treegrid/actions/edit.ts +1083 -0
- package/dist/ts/treegrid/actions/excel-export.d.ts +67 -0
- package/dist/ts/treegrid/actions/excel-export.ts +240 -0
- package/dist/ts/treegrid/actions/filter.d.ts +57 -0
- package/dist/ts/treegrid/actions/filter.ts +231 -0
- package/dist/ts/treegrid/actions/freeze-column.d.ts +28 -0
- package/dist/ts/treegrid/actions/freeze-column.ts +119 -0
- package/dist/ts/treegrid/actions/index.d.ts +24 -0
- package/dist/ts/treegrid/actions/index.ts +24 -0
- package/dist/ts/treegrid/actions/infinite-scroll.d.ts +96 -0
- package/dist/ts/treegrid/actions/infinite-scroll.ts +320 -0
- package/dist/ts/treegrid/actions/logger.d.ts +25 -0
- package/dist/ts/treegrid/actions/logger.ts +136 -0
- package/dist/ts/treegrid/actions/page.d.ts +67 -0
- package/dist/ts/treegrid/actions/page.ts +212 -0
- package/dist/ts/treegrid/actions/pdf-export.d.ts +63 -0
- package/dist/ts/treegrid/actions/pdf-export.ts +182 -0
- package/dist/ts/treegrid/actions/print.d.ts +37 -0
- package/dist/ts/treegrid/actions/print.ts +69 -0
- package/dist/ts/treegrid/actions/reorder.d.ts +36 -0
- package/dist/ts/treegrid/actions/reorder.ts +60 -0
- package/dist/ts/treegrid/actions/resize.d.ts +36 -0
- package/dist/ts/treegrid/actions/resize.ts +54 -0
- package/dist/ts/treegrid/actions/rowdragdrop.d.ts +405 -0
- package/dist/ts/treegrid/actions/rowdragdrop.ts +1896 -0
- package/dist/ts/treegrid/actions/selection.d.ts +51 -0
- package/dist/ts/treegrid/actions/selection.ts +530 -0
- package/dist/ts/treegrid/actions/sort.d.ts +63 -0
- package/dist/ts/treegrid/actions/sort.ts +149 -0
- package/dist/ts/treegrid/actions/summary.d.ts +47 -0
- package/dist/ts/treegrid/actions/summary.ts +231 -0
- package/dist/ts/treegrid/actions/toolbar.d.ts +52 -0
- package/dist/ts/treegrid/actions/toolbar.ts +154 -0
- package/dist/ts/treegrid/actions/virtual-scroll.d.ts +90 -0
- package/dist/ts/treegrid/actions/virtual-scroll.ts +306 -0
- package/dist/ts/treegrid/base/constant.d.ts +158 -0
- package/dist/ts/treegrid/base/constant.ts +158 -0
- package/dist/ts/treegrid/base/data.d.ts +90 -0
- package/dist/ts/treegrid/base/data.ts +904 -0
- package/dist/ts/treegrid/base/index.d.ts +11 -0
- package/dist/ts/treegrid/base/index.ts +11 -0
- package/dist/ts/treegrid/base/interface.d.ts +186 -0
- package/dist/ts/treegrid/base/interface.ts +191 -0
- package/dist/ts/treegrid/base/treegrid-model.d.ts +1100 -0
- package/dist/ts/treegrid/base/treegrid.d.ts +2422 -0
- package/dist/ts/treegrid/base/treegrid.ts +5962 -0
- package/dist/ts/treegrid/enum.d.ts +152 -0
- package/dist/ts/treegrid/enum.ts +217 -0
- package/dist/ts/treegrid/index.d.ts +9 -0
- package/dist/ts/treegrid/index.ts +9 -0
- package/dist/ts/treegrid/models/column-chooser-settings-model.d.ts +62 -0
- package/dist/ts/treegrid/models/column-chooser-settings.d.ts +53 -0
- package/dist/ts/treegrid/models/column-chooser-settings.ts +67 -0
- package/dist/ts/treegrid/models/column-model.d.ts +30 -0
- package/dist/ts/treegrid/models/column.d.ts +697 -0
- package/dist/ts/treegrid/models/column.ts +800 -0
- package/dist/ts/treegrid/models/edit-settings-model.d.ts +100 -0
- package/dist/ts/treegrid/models/edit-settings.d.ts +89 -0
- package/dist/ts/treegrid/models/edit-settings.ts +111 -0
- package/dist/ts/treegrid/models/filter-settings-model.d.ts +216 -0
- package/dist/ts/treegrid/models/filter-settings.d.ts +195 -0
- package/dist/ts/treegrid/models/filter-settings.ts +237 -0
- package/dist/ts/treegrid/models/index.d.ts +24 -0
- package/dist/ts/treegrid/models/index.ts +24 -0
- package/dist/ts/treegrid/models/infinite-scroll-settings-model.d.ts +29 -0
- package/dist/ts/treegrid/models/infinite-scroll-settings.d.ts +25 -0
- package/dist/ts/treegrid/models/infinite-scroll-settings.ts +31 -0
- package/dist/ts/treegrid/models/loading-indicator-model.d.ts +21 -0
- package/dist/ts/treegrid/models/loading-indicator.d.ts +19 -0
- package/dist/ts/treegrid/models/loading-indicator.ts +21 -0
- package/dist/ts/treegrid/models/page-settings-model.d.ts +66 -0
- package/dist/ts/treegrid/models/page-settings.d.ts +57 -0
- package/dist/ts/treegrid/models/page-settings.ts +73 -0
- package/dist/ts/treegrid/models/rowdrop-settings-model.d.ts +15 -0
- package/dist/ts/treegrid/models/rowdrop-settings.d.ts +34 -0
- package/dist/ts/treegrid/models/rowdrop-settings.ts +37 -0
- package/dist/ts/treegrid/models/search-settings-model.d.ts +79 -0
- package/dist/ts/treegrid/models/search-settings.d.ts +73 -0
- package/dist/ts/treegrid/models/search-settings.ts +83 -0
- package/dist/ts/treegrid/models/selection-settings-model.d.ts +76 -0
- package/dist/ts/treegrid/models/selection-settings.d.ts +68 -0
- package/dist/ts/treegrid/models/selection-settings.ts +82 -0
- package/dist/ts/treegrid/models/sort-settings-model.d.ts +49 -0
- package/dist/ts/treegrid/models/sort-settings.d.ts +43 -0
- package/dist/ts/treegrid/models/sort-settings.ts +51 -0
- package/dist/ts/treegrid/models/summary-model.d.ts +93 -0
- package/dist/ts/treegrid/models/summary.d.ts +126 -0
- package/dist/ts/treegrid/models/summary.ts +170 -0
- package/dist/ts/treegrid/models/textwrap-settings-model.d.ts +21 -0
- package/dist/ts/treegrid/models/textwrap-settings.d.ts +19 -0
- package/dist/ts/treegrid/models/textwrap-settings.ts +21 -0
- package/dist/ts/treegrid/renderer/index.d.ts +5 -0
- package/dist/ts/treegrid/renderer/index.ts +5 -0
- package/dist/ts/treegrid/renderer/render.d.ts +41 -0
- package/dist/ts/treegrid/renderer/render.ts +379 -0
- package/dist/ts/treegrid/renderer/virtual-row-model-generator.d.ts +16 -0
- package/dist/ts/treegrid/renderer/virtual-row-model-generator.ts +90 -0
- package/dist/ts/treegrid/renderer/virtual-tree-content-render.d.ts +353 -0
- package/dist/ts/treegrid/renderer/virtual-tree-content-render.ts +1125 -0
- package/dist/ts/treegrid/utils.d.ts +70 -0
- package/dist/ts/treegrid/utils.ts +217 -0
- package/package.json +51 -15
- package/src/treegrid/actions/context-menu.js +3 -1
- package/src/treegrid/actions/excel-export.d.ts +8 -0
- package/src/treegrid/actions/excel-export.js +13 -1
- package/src/treegrid/actions/freeze-column.js +1 -1
- package/src/treegrid/actions/pdf-export.d.ts +8 -0
- package/src/treegrid/actions/pdf-export.js +12 -0
- package/src/treegrid/actions/selection.js +1 -1
- package/src/treegrid/actions/virtual-scroll.js +2 -2
- package/src/treegrid/base/data.js +1 -1
- package/src/treegrid/base/treegrid-model.d.ts +32 -2
- package/src/treegrid/base/treegrid.d.ts +29 -2
- package/src/treegrid/base/treegrid.js +39 -2
- package/src/treegrid/models/column-chooser-settings-model.d.ts +62 -0
- package/src/treegrid/models/column-chooser-settings.d.ts +53 -0
- package/src/treegrid/models/column-chooser-settings.js +52 -0
- package/src/treegrid/renderer/virtual-tree-content-render.js +4 -9
- package/src/treegrid/utils.js +22 -6
|
@@ -0,0 +1,904 @@
|
|
|
1
|
+
import { extend, isNullOrUndefined, setValue, getValue, addClass, removeClass } from '@syncfusion/ej2-base';
|
|
2
|
+
import { DataManager, Query, Group, DataUtil, QueryOptions, ReturnOption, ParamOption } from '@syncfusion/ej2-data';
|
|
3
|
+
import { ITreeData, RowExpandedEventArgs } from './interface';
|
|
4
|
+
import { TreeGrid } from './treegrid';
|
|
5
|
+
import { showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
|
|
6
|
+
import { getObject, BeforeDataBoundArgs, VirtualContentRenderer, getUid, Row, Column } from '@syncfusion/ej2-grids';
|
|
7
|
+
import { ColumnModel as GridColumnModel, NotifyArgs, SaveEventArgs, Action, VirtualInfo } from '@syncfusion/ej2-grids';
|
|
8
|
+
import { isRemoteData, isOffline, isCountRequired, getExpandStatus } from '../utils';
|
|
9
|
+
import * as events from './constant';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dataoperations for tree grid
|
|
13
|
+
*
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
16
|
+
export class DataManipulation {
|
|
17
|
+
//Internal variables
|
|
18
|
+
private taskIds: Object[];
|
|
19
|
+
private parentItems: Object[];
|
|
20
|
+
private zerothLevelData: BeforeDataBoundArgs;
|
|
21
|
+
private storedIndex: number;
|
|
22
|
+
private batchChanges: Object;
|
|
23
|
+
private addedRecords: string = 'addedRecords';
|
|
24
|
+
private parent: TreeGrid;
|
|
25
|
+
private dataResults: ReturnOption;
|
|
26
|
+
private sortedData: Object[];
|
|
27
|
+
private hierarchyData: Object[];
|
|
28
|
+
private isSelfReference: boolean;
|
|
29
|
+
private isSortAction: boolean;
|
|
30
|
+
private infiniteScrollData: Object[];
|
|
31
|
+
constructor(grid: TreeGrid) {
|
|
32
|
+
this.parent = grid;
|
|
33
|
+
this.parentItems = [];
|
|
34
|
+
this.taskIds = [];
|
|
35
|
+
this.hierarchyData = [];
|
|
36
|
+
this.storedIndex = -1;
|
|
37
|
+
this.sortedData = [];
|
|
38
|
+
this.isSortAction = false;
|
|
39
|
+
this.addEventListener();
|
|
40
|
+
this.dataResults = <ReturnOption>{};
|
|
41
|
+
this.isSelfReference = !isNullOrUndefined(this.parent.parentIdMapping);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @hidden
|
|
46
|
+
* @returns {void}
|
|
47
|
+
*/
|
|
48
|
+
public addEventListener(): void {
|
|
49
|
+
this.parent.on('updateRemoteLevel', this.updateParentRemoteData, this);
|
|
50
|
+
this.parent.grid.on('sorting-begin', this.beginSorting, this);
|
|
51
|
+
this.parent.on('updateAction', this.updateData, this);
|
|
52
|
+
this.parent.on(events.remoteExpand, this.collectExpandingRecs, this);
|
|
53
|
+
this.parent.on('dataProcessor', this.dataProcessor, this);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @hidden
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
public removeEventListener(): void {
|
|
61
|
+
if (this.parent.isDestroyed) { return; }
|
|
62
|
+
this.parent.off(events.remoteExpand, this.collectExpandingRecs);
|
|
63
|
+
this.parent.off('updateRemoteLevel', this.updateParentRemoteData);
|
|
64
|
+
this.parent.off('updateAction', this.updateData);
|
|
65
|
+
this.parent.off('dataProcessor', this.dataProcessor);
|
|
66
|
+
this.parent.grid.off('sorting-begin', this.beginSorting);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* To destroy the dataModule
|
|
71
|
+
*
|
|
72
|
+
* @returns {void}
|
|
73
|
+
* @hidden
|
|
74
|
+
*/
|
|
75
|
+
public destroy(): void {
|
|
76
|
+
this.removeEventListener();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @hidden
|
|
81
|
+
* @returns {boolean} -Returns whether remote data binding
|
|
82
|
+
*/
|
|
83
|
+
public isRemote(): boolean {
|
|
84
|
+
if (!(this.parent.dataSource instanceof DataManager)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
// let gridData: DataManager = <DataManager>this.parent.dataSource;
|
|
89
|
+
// return gridData.dataSource.offline !== true && gridData.dataSource.url !== undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Function to manipulate datasource
|
|
94
|
+
*
|
|
95
|
+
* @param {Object} data - Provide tree grid datasource to convert to flat data
|
|
96
|
+
* @hidden
|
|
97
|
+
* @returns {void}
|
|
98
|
+
*/
|
|
99
|
+
public convertToFlatData(data: Object): void {
|
|
100
|
+
this.parent.flatData = <Object[]>(!isNullOrUndefined(data) && Object.keys(data).length === 0
|
|
101
|
+
&& !(this.parent.dataSource instanceof DataManager) ?
|
|
102
|
+
this.parent.dataSource : []);
|
|
103
|
+
this.parent.parentData = [];
|
|
104
|
+
if ((isRemoteData(this.parent) && !isOffline(this.parent)) && data instanceof DataManager && !(data instanceof Array)) {
|
|
105
|
+
const dm: DataManager = <DataManager>this.parent.dataSource;
|
|
106
|
+
if (this.parent.parentIdMapping) {
|
|
107
|
+
this.parent.query = isNullOrUndefined(this.parent.query) ?
|
|
108
|
+
new Query() : this.parent.query;
|
|
109
|
+
if (this.parent.parentIdMapping) {
|
|
110
|
+
const filterKey: Object[] = this.parent.query.params.filter((param: ParamOption) => param.key === 'IdMapping');
|
|
111
|
+
if (this.parent.initialRender && !filterKey.length) {
|
|
112
|
+
this.parent.query.where(this.parent.parentIdMapping, 'equal', null);
|
|
113
|
+
this.parent.query.addParams('IdMapping', this.parent.idMapping);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (!this.parent.hasChildMapping) {
|
|
117
|
+
let qry: Query = this.parent.query.clone();
|
|
118
|
+
qry.queries = [];
|
|
119
|
+
qry = qry.select([this.parent.parentIdMapping]);
|
|
120
|
+
qry.isCountRequired = true;
|
|
121
|
+
dm.executeQuery(qry).then((e: ReturnOption) => {
|
|
122
|
+
this.parentItems = DataUtil.distinct(<Object[]>e.result, this.parent.parentIdMapping, false);
|
|
123
|
+
let req: number;
|
|
124
|
+
if (<Object[]>e.result) {
|
|
125
|
+
req = 0;
|
|
126
|
+
} else {
|
|
127
|
+
req = 1;
|
|
128
|
+
}
|
|
129
|
+
if (req === 0) {
|
|
130
|
+
setValue('grid.contentModule.isLoaded', true, this.parent);
|
|
131
|
+
if (!isNullOrUndefined(this.zerothLevelData)) {
|
|
132
|
+
setValue('cancel', false, this.zerothLevelData);
|
|
133
|
+
getValue('grid.renderModule', this.parent).dataManagerSuccess(this.zerothLevelData);
|
|
134
|
+
this.zerothLevelData = null;
|
|
135
|
+
}
|
|
136
|
+
this.parent.grid.hideSpinner();
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} else if (data instanceof Array) {
|
|
142
|
+
this.convertJSONData(data);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private convertJSONData(data: Object): void {
|
|
147
|
+
this.hierarchyData = [];
|
|
148
|
+
this.taskIds = [];
|
|
149
|
+
if (!this.parent.idMapping) {
|
|
150
|
+
this.hierarchyData = <Object[]> data;
|
|
151
|
+
} else {
|
|
152
|
+
const keys: string[] = Object.keys(data);
|
|
153
|
+
for (let i: number = 0; i < keys.length; i++) {
|
|
154
|
+
const tempData: Object = data[parseInt(i.toString(), 10)];
|
|
155
|
+
this.hierarchyData.push(extend({}, tempData));
|
|
156
|
+
if (!isNullOrUndefined(tempData[this.parent.idMapping])) {
|
|
157
|
+
this.taskIds.push(tempData[this.parent.idMapping]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (this.isSelfReference) {
|
|
162
|
+
const selfData: ITreeData[] = [];
|
|
163
|
+
const mappingData: Object[] = new DataManager(this.hierarchyData).executeLocal(
|
|
164
|
+
new Query()
|
|
165
|
+
.group(this.parent.parentIdMapping)
|
|
166
|
+
);
|
|
167
|
+
for (let i: number = 0; i < mappingData.length; i++) {
|
|
168
|
+
const groupData: Group = mappingData[parseInt(i.toString(), 10)];
|
|
169
|
+
const index: number = this.taskIds.indexOf(groupData.key);
|
|
170
|
+
if (!isNullOrUndefined(groupData.key)) {
|
|
171
|
+
if (index > -1) {
|
|
172
|
+
const childData: Object[] = (groupData.items);
|
|
173
|
+
this.hierarchyData[parseInt(index.toString(), 10)][this.parent.childMapping] = childData;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
selfData.push(...groupData.items);
|
|
178
|
+
}
|
|
179
|
+
this.hierarchyData = this.selfReferenceUpdate(selfData);
|
|
180
|
+
}
|
|
181
|
+
if (!Object.keys(this.hierarchyData).length) {
|
|
182
|
+
const isGantt: string = 'isGantt';
|
|
183
|
+
const referenceData: boolean = !(this.parent.dataSource instanceof DataManager) && this.parent[`${isGantt}`];
|
|
184
|
+
this.parent.flatData = referenceData ? <Object[]>(this.parent.dataSource) : [];
|
|
185
|
+
} else {
|
|
186
|
+
this.createRecords(this.hierarchyData);
|
|
187
|
+
}
|
|
188
|
+
this.storedIndex = -1;
|
|
189
|
+
}
|
|
190
|
+
// private crudActions(): void {
|
|
191
|
+
// if (this.parent.dataSource instanceof DataManager && (this.parent.dataSource.adaptor instanceof RemoteSaveAdaptor)) {
|
|
192
|
+
// let oldUpdate: Function = this.parent.dataSource.adaptor.update;
|
|
193
|
+
// this.parent.dataSource.adaptor.update =
|
|
194
|
+
// function (dm: DataManager, keyField: string, value: Object, tableName?: string, query?: Query, original?: Object): Object {
|
|
195
|
+
// value = getPlainData(value);
|
|
196
|
+
// return oldUpdate.apply(this, [dm, keyField, value, tableName, query, original]);
|
|
197
|
+
// }
|
|
198
|
+
// }
|
|
199
|
+
// }
|
|
200
|
+
private selfReferenceUpdate(selfData: ITreeData[]): ITreeData[] {
|
|
201
|
+
const result: ITreeData[] = [];
|
|
202
|
+
while (this.hierarchyData.length > 0 && selfData.length > 0) {
|
|
203
|
+
const index: number = selfData.indexOf(this.hierarchyData[0]);
|
|
204
|
+
if ( index === -1) {
|
|
205
|
+
this.hierarchyData.shift();
|
|
206
|
+
} else {
|
|
207
|
+
result.push(this.hierarchyData.shift());
|
|
208
|
+
selfData.splice(index, 1);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Function to update the zeroth level parent records in remote binding
|
|
215
|
+
*
|
|
216
|
+
* @param {BeforeDataBoundArgs} args - contains data before its bounds to tree grid
|
|
217
|
+
* @hidden
|
|
218
|
+
* @returns {void}
|
|
219
|
+
*/
|
|
220
|
+
private updateParentRemoteData(args?: BeforeDataBoundArgs) : void {
|
|
221
|
+
const actionArgs: string = 'actionArgs';
|
|
222
|
+
if (isRemoteData(this.parent) && this.parent.enableVirtualization && args[`${actionArgs}`].requestType === 'virtualscroll' ) {
|
|
223
|
+
this.parent.hideSpinner();
|
|
224
|
+
}
|
|
225
|
+
const records: ITreeData[] = args.result;
|
|
226
|
+
if (isRemoteData(this.parent) && this.parent.enableVirtualization && (args[`${actionArgs}`].requestType === 'virtualscroll' || args[`${actionArgs}`].action === 'clearFilter' || args[`${actionArgs}`].searchString === '')) {
|
|
227
|
+
this.parent.query.expands = [];
|
|
228
|
+
}
|
|
229
|
+
if (!this.parent.hasChildMapping && !this.parentItems.length &&
|
|
230
|
+
(this.parent.loadChildOnDemand)) {
|
|
231
|
+
this.zerothLevelData = args;
|
|
232
|
+
setValue('cancel', true, args);
|
|
233
|
+
} else {
|
|
234
|
+
if (this.parent.loadChildOnDemand) {
|
|
235
|
+
for (let rec: number = 0; rec < records.length; rec++) {
|
|
236
|
+
if (isCountRequired(this.parent) && records[parseInt(rec.toString(), 10)].hasChildRecords &&
|
|
237
|
+
this.parent.initialRender) {
|
|
238
|
+
records[parseInt(rec.toString(), 10)].expanded = false;
|
|
239
|
+
}
|
|
240
|
+
if (isRemoteData(this.parent) && this.parent.enableVirtualization) {
|
|
241
|
+
const childRecords: ITreeData[] = [];
|
|
242
|
+
const parent: TreeGrid = this.parent;
|
|
243
|
+
records.filter((e: ITreeData): void => {
|
|
244
|
+
if (e[`${parent.parentIdMapping}`] === records[parseInt(rec.toString(), 10)][`${parent.idMapping}`]) {
|
|
245
|
+
childRecords.push(e);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
if (childRecords.length) {
|
|
249
|
+
records[parseInt(rec.toString(), 10)].expanded = true;
|
|
250
|
+
}
|
|
251
|
+
else if (records[parseInt(rec.toString(), 10)].hasChildRecords) {
|
|
252
|
+
records[parseInt(rec.toString(), 10)].expanded = false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (isNullOrUndefined(records[parseInt(rec.toString(), 10)].index)) {
|
|
256
|
+
records[parseInt(rec.toString(), 10)].taskData = extend({}, records[parseInt(rec.toString(), 10)]);
|
|
257
|
+
records[parseInt(rec.toString(), 10)].uniqueID = getUid(this.parent.element.id + '_data_');
|
|
258
|
+
setValue('uniqueIDCollection.' + records[parseInt(rec.toString(), 10)].uniqueID, records[parseInt(rec.toString(), 10)], this.parent);
|
|
259
|
+
if (isRemoteData(this.parent) && this.parent.enableVirtualization && records[parseInt(rec.toString(), 10)][`${this.parent.parentIdMapping}`] && (isNullOrUndefined(records[parseInt(rec.toString(), 10)].level) || records[parseInt(rec.toString(), 10)].level === 0)) {
|
|
260
|
+
const parentID: any = records[parseInt(rec.toString(), 10)][`${this.parent.parentIdMapping}`];
|
|
261
|
+
const parentRec: any = records.find((record: any) => record[`${this.parent.idMapping}`] === parentID);
|
|
262
|
+
if (parentRec) {
|
|
263
|
+
records[parseInt(rec.toString(), 10)].level = parentRec.level + 1;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
const parentRec: any = (args.actual as any).flatData.find((record: any) => record[`${this.parent.idMapping}`] === parentID);
|
|
267
|
+
if (isNullOrUndefined(parentRec[`${this.parent.parentIdMapping}`])) {
|
|
268
|
+
records[parseInt(rec.toString(), 10)].level = 1;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
records[parseInt(rec.toString(), 10)].level = parentRec.level + 1;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
records[parseInt(rec.toString(), 10)].level = 0;
|
|
277
|
+
}
|
|
278
|
+
records[parseInt(rec.toString(), 10)].index = Math.ceil(Math.random() * 1000);
|
|
279
|
+
if ((records[parseInt(rec.toString(), 10)][this.parent.hasChildMapping] ||
|
|
280
|
+
this.parentItems.indexOf(records[parseInt(rec.toString(), 10)][this.parent.idMapping]) !== -1)) {
|
|
281
|
+
records[parseInt(rec.toString(), 10)].hasChildRecords = true;
|
|
282
|
+
}
|
|
283
|
+
records[parseInt(rec.toString(), 10)].checkboxState = 'uncheck';
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
} else {
|
|
287
|
+
const dataResults: string = 'dataResults';
|
|
288
|
+
const expandRecord: string = 'expandRecord';
|
|
289
|
+
if (!isNullOrUndefined(records) && !((!this.parent.loadChildOnDemand) && isCountRequired(this.parent) && !isNullOrUndefined(this.parent[`${dataResults}`][`${expandRecord}`])) &&
|
|
290
|
+
!(isRemoteData(this.parent) && !this.parent.loadChildOnDemand && args[`${actionArgs}`].isExpandCollapse && this.parent.enableVirtualization)) {
|
|
291
|
+
this.convertToFlatData(records);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (isRemoteData(this.parent) && !this.parent.loadChildOnDemand && args[`${actionArgs}`].isExpandCollapse && this.parent.enableVirtualization) {
|
|
296
|
+
args.result = records;
|
|
297
|
+
}
|
|
298
|
+
else if (isRemoteData(this.parent) && this.parent.enableVirtualization && this.parent.loadChildOnDemand) {
|
|
299
|
+
args.result = records;
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
args.result = !this.parent.loadChildOnDemand ? this.parent.flatData : records;
|
|
303
|
+
}
|
|
304
|
+
if (isRemoteData(this.parent) && this.parent.enableVirtualization && !this.parent.loadChildOnDemand
|
|
305
|
+
&& this.parent.grid.aggregates.length && this.parent.grid.sortSettings.columns.length === 0
|
|
306
|
+
&& this.parent.grid.filterSettings.columns.length === 0 && !this.parent.grid.searchSettings.key.length) {
|
|
307
|
+
const query: string = 'query';
|
|
308
|
+
const summaryQuery: QueryOptions[] = args[`${query}`].queries.filter((q: QueryOptions) => q.fn === 'onAggregates');
|
|
309
|
+
args.result = this.parent.summaryModule.calculateSummaryValue(summaryQuery, this.parent.flatData, true);
|
|
310
|
+
}
|
|
311
|
+
this.parent.notify('updateResults', args);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Function to manipulate datasource
|
|
316
|
+
*
|
|
317
|
+
* @param {{record: ITreeData, rows: HTMLTableRowElement[], parentRow: HTMLTableRowElement}} rowDetails - Row details for which child rows has to be fetched
|
|
318
|
+
* @param {ITreeData} rowDetails.record - current expanding record
|
|
319
|
+
* @param {HTMLTableRowElement[]} rowDetails.rows - Expanding Row element
|
|
320
|
+
* @param {HTMLTableRowElement} rowDetails.parentRow - Curent expanding row element
|
|
321
|
+
* @param {boolean} isChild - Specified whether current record is already a child record
|
|
322
|
+
* @hidden
|
|
323
|
+
* @returns {void}
|
|
324
|
+
*/
|
|
325
|
+
private collectExpandingRecs(rowDetails: {record: ITreeData, rows: HTMLTableRowElement[], parentRow: HTMLTableRowElement},
|
|
326
|
+
isChild?: boolean): void {
|
|
327
|
+
let gridRows: HTMLTableRowElement[] = this.parent.getRows();
|
|
328
|
+
const name: string = 'name';
|
|
329
|
+
if (this.parent.rowTemplate) {
|
|
330
|
+
const rows: HTMLCollection = (this.parent.getContentTable() as HTMLTableElement).rows;
|
|
331
|
+
gridRows = [].slice.call(rows);
|
|
332
|
+
}
|
|
333
|
+
let childRecord: ITreeData;
|
|
334
|
+
if (rowDetails.rows.length > 0) {
|
|
335
|
+
if (!isChild) {
|
|
336
|
+
rowDetails.record.expanded = true;
|
|
337
|
+
}
|
|
338
|
+
for (let i: number = 0; i < rowDetails.rows.length; i++) {
|
|
339
|
+
this.parent['toggleRowVisibility'](rowDetails.rows[parseInt(i.toString(), 10)], 'e-childrow-visible');
|
|
340
|
+
if (!this.parent.loadChildOnDemand) {
|
|
341
|
+
const targetEle: Element = rowDetails.rows[parseInt(i.toString(), 10)].getElementsByClassName('e-treegridcollapse')[0];
|
|
342
|
+
childRecord = this.parent.rowTemplate ?
|
|
343
|
+
this.parent.grid.getCurrentViewRecords()[rowDetails.rows[parseInt(i.toString(), 10)].rowIndex] :
|
|
344
|
+
this.parent.grid.getRowObjectFromUID(rowDetails.rows[parseInt(i.toString(), 10)].getAttribute('data-uid')).data;
|
|
345
|
+
if (!isNullOrUndefined(targetEle) && childRecord.expanded) {
|
|
346
|
+
addClass([targetEle], 'e-treegridexpand');
|
|
347
|
+
removeClass([targetEle], 'e-treegridcollapse');
|
|
348
|
+
}
|
|
349
|
+
let childRows: HTMLTableRowElement[] = [];
|
|
350
|
+
childRows = gridRows.filter(
|
|
351
|
+
(r: HTMLTableRowElement) =>
|
|
352
|
+
r.querySelector(
|
|
353
|
+
'.e-gridrowindex' + childRecord.index + 'level' + (childRecord.level + 1)
|
|
354
|
+
)
|
|
355
|
+
);
|
|
356
|
+
if (childRows.length && childRecord.expanded) {
|
|
357
|
+
this.collectExpandingRecs({ record: childRecord, rows: childRows, parentRow: rowDetails.parentRow }, true);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const expandingTd: Element = rowDetails.rows[parseInt(i.toString(), 10)].querySelector('.e-detailrowcollapse');
|
|
361
|
+
if (!isNullOrUndefined(expandingTd)) {
|
|
362
|
+
this.parent.grid.detailRowModule.expand(expandingTd);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
this.parent.grid.pageSettings.totalRecordsCount += rowDetails.rows.length;
|
|
366
|
+
} else {
|
|
367
|
+
this.fetchRemoteChildData({action: rowDetails[`${name}`], record: rowDetails.record, rows: rowDetails.rows, parentRow: rowDetails.parentRow});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
private fetchRemoteChildData(rowDetails: { action: string, record: ITreeData, rows: HTMLTableRowElement[],
|
|
372
|
+
parentRow: HTMLTableRowElement }): void {
|
|
373
|
+
const args: RowExpandedEventArgs = {row: rowDetails.parentRow, data: rowDetails.record};
|
|
374
|
+
const dm: DataManager = <DataManager>this.parent.dataSource;
|
|
375
|
+
const query: Query = this.parent.grid.getDataModule().generateQuery();
|
|
376
|
+
const clonequries: QueryOptions[] = query.queries.filter((e: QueryOptions) => e.fn !== 'onPage' && e.fn !== 'onWhere');
|
|
377
|
+
query.queries = clonequries;
|
|
378
|
+
query.isCountRequired = true;
|
|
379
|
+
let idMappingValue: number | string = parseInt(rowDetails.record[this.parent.idMapping], 10);
|
|
380
|
+
if (isNaN(idMappingValue)) {
|
|
381
|
+
idMappingValue = rowDetails.record[this.parent.idMapping].toString();
|
|
382
|
+
}
|
|
383
|
+
if (this.parent.enableVirtualization && rowDetails.action === 'remoteExpand') {
|
|
384
|
+
query.take(this.parent.grid.pageSettings.pageSize);
|
|
385
|
+
const expandDetail: Object[] = [];
|
|
386
|
+
expandDetail.push('ExpandingAction', idMappingValue.toString());
|
|
387
|
+
query.expand(expandDetail);
|
|
388
|
+
}
|
|
389
|
+
else if (this.parent.enableVirtualization && rowDetails.action === 'collapse') {
|
|
390
|
+
query.take(this.parent.grid.pageSettings.pageSize);
|
|
391
|
+
const expandDetail: Object[] = [];
|
|
392
|
+
expandDetail.push('CollapsingAction', idMappingValue.toString());
|
|
393
|
+
query.expand(expandDetail);
|
|
394
|
+
}
|
|
395
|
+
query.where(this.parent.parentIdMapping, 'equal', rowDetails.record[this.parent.idMapping]);
|
|
396
|
+
if (rowDetails.action === 'remoteExpand' && this.parent.grid.filterSettings && this.parent.grid.filterSettings.columns.length) {
|
|
397
|
+
const filterqry: QueryOptions[] = this.parent.grid.getDataModule().generateQuery().queries.filter((e: QueryOptions) => e.fn !== 'onPage' && typeof e.e.predicates !== 'undefined');
|
|
398
|
+
query.queries.push(filterqry[0]);
|
|
399
|
+
}
|
|
400
|
+
showSpinner(this.parent.element);
|
|
401
|
+
dm.executeQuery(query).then((e: ReturnOption) => {
|
|
402
|
+
const remoteExpandedData: string = 'remoteExpandedData';
|
|
403
|
+
const remoteCollapsedData: string = 'remoteCollapsedData';
|
|
404
|
+
const level: string = 'level';
|
|
405
|
+
let datas: ITreeData[] = this.parent.grid.currentViewData.slice();
|
|
406
|
+
let inx: number;
|
|
407
|
+
const idMapping: string = this.parent.idMapping;
|
|
408
|
+
if (this.parent['isGantt'] && this.parent.loadChildOnDemand && this.parent.hasChildMapping) {
|
|
409
|
+
for (let i: number = 0; i < this.parent.grid.currentViewData.length; i++) {
|
|
410
|
+
if (rowDetails.record[idMapping as string] === this.parent.grid.currentViewData[i as number][idMapping as string]) {
|
|
411
|
+
inx = i;
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
inx = datas.indexOf(rowDetails.record);
|
|
418
|
+
}
|
|
419
|
+
if (this.parent.enableVirtualization && (rowDetails.action === 'collapse' || rowDetails.action === 'remoteExpand')) {
|
|
420
|
+
datas = [];
|
|
421
|
+
for (let i: number = 0; i < inx; i++) {
|
|
422
|
+
datas.push(this.parent.grid.currentViewData[parseInt(i.toString(), 10)]);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
if (inx === -1) {
|
|
426
|
+
this.parent.grid.getRowsObject().forEach((rows: Row<Column>) => {
|
|
427
|
+
if ((rows.data as ITreeData).uniqueID === rowDetails.record.uniqueID) {
|
|
428
|
+
inx = rows.index;
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
const haveChild: boolean[] = getObject('actual.nextLevel', e);
|
|
433
|
+
let result: ITreeData[] = <ITreeData[]>e.result;
|
|
434
|
+
const resultChildData: ITreeData[] = [];
|
|
435
|
+
if (rowDetails.action === 'remoteExpand' && this.parent.grid.filterModule && this.parent.grid.filterModule['value']) {
|
|
436
|
+
for (let i: number = 0; i < datas.length; i++) {
|
|
437
|
+
if (Object.prototype.hasOwnProperty.call(datas[parseInt(i.toString(), 10)], this.parent.parentIdMapping) && datas[parseInt(i.toString(), 10)]['' + this.parent.parentIdMapping] !== null && datas[parseInt(i.toString(), 10)].level === 0) {
|
|
438
|
+
datas.splice(i, 1);
|
|
439
|
+
i--;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
for (let i: number = 0; i < result.length; i++) {
|
|
443
|
+
if (rowDetails.record['' + this.parent.idMapping] !== result[parseInt(i.toString(), 10)]['' + this.parent.idMapping] &&
|
|
444
|
+
rowDetails.record['' + this.parent.idMapping] === result[parseInt(i.toString(), 10)]['' + this.parent.parentIdMapping]) {
|
|
445
|
+
if (Object.prototype.hasOwnProperty.call(result, i)) {
|
|
446
|
+
resultChildData.push(result[parseInt(i.toString(), 10)]);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
result = resultChildData;
|
|
451
|
+
}
|
|
452
|
+
if (this.parent.enableVirtualization && rowDetails.action === 'remoteExpand') {
|
|
453
|
+
rowDetails.record.childRecords = [];
|
|
454
|
+
for (let i: number = 0; i < result.length; i++) {
|
|
455
|
+
if (rowDetails.record['' + this.parent.idMapping] !== result[parseInt(i.toString(), 10)]['' + this.parent.idMapping] &&
|
|
456
|
+
rowDetails.record['' + this.parent.idMapping] === result[parseInt(i.toString(), 10)]['' + this.parent.parentIdMapping] && Object.prototype.hasOwnProperty.call(result, i)) {
|
|
457
|
+
rowDetails.record.childRecords.push(result[parseInt(i.toString(), 10)]);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
rowDetails.record.childRecords = result;
|
|
463
|
+
}
|
|
464
|
+
for (let r: number = 0; r < result.length; r++) {
|
|
465
|
+
const record: any = result[parseInt(r.toString(), 10)];
|
|
466
|
+
if (this.parent.enableVirtualization && record[`${this.parent.idMapping}`] === rowDetails.record[`${this.parent.idMapping}`] && rowDetails.action === 'remoteExpand') {
|
|
467
|
+
this.parent[`${remoteExpandedData}`].push(rowDetails.record);
|
|
468
|
+
}
|
|
469
|
+
else if (this.parent.enableVirtualization && record[`${this.parent.idMapping}`] === rowDetails.record[`${this.parent.idMapping}`] && rowDetails.action === 'collapse') {
|
|
470
|
+
for (let i: number = 0; i < this.parent[`${remoteExpandedData}`].length; i++) {
|
|
471
|
+
if (rowDetails.record[`${this.parent.idMapping}`] === this.parent[`${remoteExpandedData}`][parseInt(i.toString(), 10)][`${this.parent.idMapping}`]) {
|
|
472
|
+
this.parent[`${remoteExpandedData}`].splice(i, 1);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
record.taskData = extend({}, record);
|
|
477
|
+
if (record[`${this.parent.parentIdMapping}`] && this.parent.enableVirtualization && this.parent[`${remoteExpandedData}`].length) {
|
|
478
|
+
for (let i: number = 0; i < this.parent[`${remoteExpandedData}`].length; i++) {
|
|
479
|
+
if (record[`${this.parent.parentIdMapping}`] === this.parent[`${remoteExpandedData}`][parseInt(i.toString(), 10)][`${this.parent.idMapping}`]) {
|
|
480
|
+
record.level = this.parent[`${remoteExpandedData}`][parseInt(i.toString(), 10)][`${level}`] + 1;
|
|
481
|
+
const parentData: ITreeData = this.parent[`${remoteExpandedData}`][parseInt(i.toString(), 10)];
|
|
482
|
+
delete parentData.childRecords;
|
|
483
|
+
record.parentItem = parentData;
|
|
484
|
+
record.parentUniqueID = parentData.uniqueID;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
else if (this.parent.enableVirtualization) {
|
|
489
|
+
if ((record[`${this.parent.hasChildMapping}`] ||
|
|
490
|
+
this.parentItems.indexOf(record[`${this.parent.idMapping}`]) !== -1)
|
|
491
|
+
&& !(haveChild && !haveChild[parseInt(r.toString(), 10)])) {
|
|
492
|
+
if (isNullOrUndefined(record[`${this.parent.parentIdMapping}`])) {
|
|
493
|
+
record.level = 0;
|
|
494
|
+
if (rowDetails.action === 'remoteExpand') {
|
|
495
|
+
record.childRecords = [];
|
|
496
|
+
record.childRecords = rowDetails.record.childRecords;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
record.level = rowDetails.record.level;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
const parentData: ITreeData = extend({}, rowDetails.record);
|
|
505
|
+
delete parentData.childRecords;
|
|
506
|
+
record.parentItem = parentData;
|
|
507
|
+
record.parentUniqueID = rowDetails.record.uniqueID;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
else {
|
|
511
|
+
record.level = rowDetails.record.level + 1;
|
|
512
|
+
const parentData: ITreeData = extend({}, rowDetails.record);
|
|
513
|
+
delete parentData.childRecords;
|
|
514
|
+
record.parentItem = parentData;
|
|
515
|
+
record.parentUniqueID = rowDetails.record.uniqueID;
|
|
516
|
+
}
|
|
517
|
+
record.index = Math.ceil(Math.random() * 1000);
|
|
518
|
+
record.uniqueID = getUid(this.parent.element.id + '_data_');
|
|
519
|
+
if (rowDetails.record[`${this.parent.idMapping}`] === record[`${this.parent.idMapping}`]) {
|
|
520
|
+
rowDetails.record.uniqueID = record.uniqueID;
|
|
521
|
+
}
|
|
522
|
+
record.checkboxState = 'uncheck';
|
|
523
|
+
if (this.parent.enableVirtualization && isNullOrUndefined(record.level)) {
|
|
524
|
+
for (let p: number = 0; p < this.parent.grid.currentViewData.length; p++) {
|
|
525
|
+
if (this.parent.grid.currentViewData[parseInt(p.toString(), 10)][`${this.parent.idMapping}`] === record[`${this.parent.parentIdMapping}`]) {
|
|
526
|
+
record.level = this.parent.grid.currentViewData[parseInt(p.toString(), 10)]['level'] + 1;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
setValue('uniqueIDCollection.' + record.uniqueID, record, this.parent);
|
|
531
|
+
// delete result[r].parentItem.childRecords;
|
|
532
|
+
if ((record[`${this.parent.hasChildMapping}`] ||
|
|
533
|
+
this.parentItems.indexOf(record[`${this.parent.idMapping}`]) !== -1)
|
|
534
|
+
&& !(haveChild && !haveChild[parseInt(r.toString(), 10)])) {
|
|
535
|
+
record.hasChildRecords = true;
|
|
536
|
+
if (this.parent.enableVirtualization && !this.parent.loadChildOnDemand) {
|
|
537
|
+
for (let i: number = 0; i < this.parent[`${remoteCollapsedData}`].length; i++) {
|
|
538
|
+
if (record[`${this.parent.idMapping}`] === this.parent[`${remoteCollapsedData}`][parseInt(i.toString(), 10)][`${this.parent.idMapping}`]) {
|
|
539
|
+
record.expanded = this.parent[`${remoteCollapsedData}`][parseInt(i.toString(), 10)]['expanded'];
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (rowDetails.action === 'collapse' && record[`${this.parent.idMapping}`] !== rowDetails.record[`${this.parent.idMapping}`] && record.expanded !== false) {
|
|
543
|
+
record.expanded = true;
|
|
544
|
+
}
|
|
545
|
+
else if (rowDetails.action === 'collapse' && record[`${this.parent.idMapping}`] === rowDetails.record[`${this.parent.idMapping}`]) {
|
|
546
|
+
record.expanded = false;
|
|
547
|
+
this.parent[`${remoteCollapsedData}`].push(rowDetails.record);
|
|
548
|
+
}
|
|
549
|
+
else if (rowDetails.action === 'remoteExpand') {
|
|
550
|
+
for (let i: number = 0; i < this.parent.grid.currentViewData.length; i++) {
|
|
551
|
+
if (this.parent.grid.currentViewData[parseInt(i.toString(), 10)][`${this.parent.idMapping}`] === record[`${this.parent.idMapping}`]) {
|
|
552
|
+
result.splice(r, 1, this.parent.grid.currentViewData[parseInt(i.toString(), 10)]);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
if (record[this.parent.idMapping] === rowDetails.record[`${this.parent.idMapping}`]) {
|
|
556
|
+
for (let i: number = 0; i < this.parent[`${remoteCollapsedData}`].length; i++) {
|
|
557
|
+
if (rowDetails.record[`${this.parent.idMapping}`] === this.parent[`${remoteCollapsedData}`][parseInt(i.toString(), 10)][`${this.parent.idMapping}`]) {
|
|
558
|
+
this.parent[`${remoteCollapsedData}`].splice(i, 1);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
if (record.expanded !== false) {
|
|
563
|
+
record.expanded = true;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
else if (this.parent.enableVirtualization && record[`${this.parent.idMapping}`] === rowDetails.record[`${this.parent.idMapping}`] && rowDetails.action !== 'collapse') {
|
|
568
|
+
record.expanded = true;
|
|
569
|
+
}
|
|
570
|
+
else if (!(this.parent.enableVirtualization && !this.parent.loadChildOnDemand)) {
|
|
571
|
+
record.expanded = false;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
const exists: boolean = datas.some((data: any) => data[`${this.parent.idMapping}`] === record[this.parent.idMapping]);
|
|
575
|
+
if (!exists) {
|
|
576
|
+
datas.splice(inx + r + 1, 0, record);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
const localIdMapping: string = this.parent.idMapping;
|
|
580
|
+
datas.sort(function (firstRecord: any, secondRecord: any): number {
|
|
581
|
+
return firstRecord[`${localIdMapping}`] - secondRecord[`${localIdMapping}`];
|
|
582
|
+
});
|
|
583
|
+
setValue('result', datas, e); setValue('action', 'beforecontentrender', e);
|
|
584
|
+
this.parent.trigger(events.actionComplete, e);
|
|
585
|
+
hideSpinner(this.parent.element);
|
|
586
|
+
if (this.parent.grid.aggregates.length > 0 && !this.parent.enableVirtualization) {
|
|
587
|
+
let gridQuery: Query = getObject('query', e);
|
|
588
|
+
const result: string = 'result';
|
|
589
|
+
if (isNullOrUndefined(gridQuery)) {
|
|
590
|
+
gridQuery = getValue('grid.renderModule.data', this.parent).aggregateQuery(new Query());
|
|
591
|
+
}
|
|
592
|
+
if (!isNullOrUndefined(gridQuery)) {
|
|
593
|
+
const summaryQuery: QueryOptions[] = gridQuery.queries.filter((q: QueryOptions) => q.fn === 'onAggregates');
|
|
594
|
+
e[`${result}`] = this.parent.summaryModule.calculateSummaryValue(summaryQuery, e[`${result}`], true);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
if (rowDetails.action === 'remoteExpand' && this.parent.allowPaging && this.parent.pageSettings.pageSizeMode === 'All') {
|
|
598
|
+
this.parent.grid.pageSettings.totalRecordsCount = this.parent.grid.pageSettings.totalRecordsCount + result.length;
|
|
599
|
+
}
|
|
600
|
+
if (this.parent.enableVirtualization) {
|
|
601
|
+
this.parent.grid.pageSettings.totalRecordsCount = e.count;
|
|
602
|
+
}
|
|
603
|
+
e.count = this.parent.grid.pageSettings.totalRecordsCount;
|
|
604
|
+
const virtualArgs: NotifyArgs = {};
|
|
605
|
+
if (this.parent.enableVirtualization) {
|
|
606
|
+
this.remoteVirtualAction(virtualArgs);
|
|
607
|
+
}
|
|
608
|
+
const notifyArgs: { index: number, childData: ITreeData[] } = { index: inx, childData : result };
|
|
609
|
+
if (this.parent.enableInfiniteScrolling) {
|
|
610
|
+
this.parent.notify('infinite-remote-expand', notifyArgs);
|
|
611
|
+
} else {
|
|
612
|
+
getValue('grid.renderModule', this.parent).dataManagerSuccess(e, virtualArgs);
|
|
613
|
+
}
|
|
614
|
+
this.parent.trigger(events.expanded, args);
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
private remoteVirtualAction(virtualArgs: NotifyArgs): void {
|
|
619
|
+
virtualArgs.requestType = 'refresh';
|
|
620
|
+
setValue('isExpandCollapse', true, virtualArgs);
|
|
621
|
+
const contentModule: VirtualContentRenderer = getValue('grid.contentModule', this.parent);
|
|
622
|
+
const currentInfo: VirtualInfo = getValue('currentInfo', contentModule);
|
|
623
|
+
const prevInfo: VirtualInfo = getValue('prevInfo', contentModule);
|
|
624
|
+
if (currentInfo.loadNext && this.parent.grid.pageSettings.currentPage === currentInfo.nextInfo.page
|
|
625
|
+
&& !this.parent.loadChildOnDemand) {
|
|
626
|
+
this.parent.grid.pageSettings.currentPage = prevInfo.page;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
private beginSorting(): void {
|
|
631
|
+
this.isSortAction = true;
|
|
632
|
+
if (isRemoteData(this.parent) && this.parent.enableVirtualization) {
|
|
633
|
+
const index: number = this.parent.query.queries.indexOf(this.parent.query.queries.filter((q: QueryOptions) => q.fn === 'onSortBy')[0]);
|
|
634
|
+
if (index !== -1) {
|
|
635
|
+
this.parent.query.queries.splice(index, 1);
|
|
636
|
+
}
|
|
637
|
+
if (this.parent.grid.sortSettings.columns.length === 0) {
|
|
638
|
+
this.parent.query.sortBy(null, null);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
private createRecords(data: Object, parentRecords?: ITreeData): ITreeData[] {
|
|
644
|
+
const treeGridData: ITreeData[] = [];
|
|
645
|
+
const keys: string[] = Object.keys(data);
|
|
646
|
+
for (let i: number = 0, len: number = keys.length; i < len; i++) {
|
|
647
|
+
const currentData: ITreeData = extend({}, data[parseInt(i.toString(), 10)]);
|
|
648
|
+
currentData.taskData = data[parseInt(i.toString(), 10)];
|
|
649
|
+
let level: number = 0;
|
|
650
|
+
this.storedIndex++;
|
|
651
|
+
if (!Object.prototype.hasOwnProperty.call(currentData, 'index')) {
|
|
652
|
+
currentData.index = this.storedIndex;
|
|
653
|
+
}
|
|
654
|
+
const childMapping: any = currentData[this.parent.childMapping];
|
|
655
|
+
const hasChildren: boolean = !isNullOrUndefined(childMapping) && childMapping.length > 0;
|
|
656
|
+
const shouldCount: boolean = isCountRequired(this.parent);
|
|
657
|
+
const hasChildMapping: any = currentData[this.parent.hasChildMapping];
|
|
658
|
+
if ((hasChildren && !shouldCount) || (hasChildMapping && shouldCount)) {
|
|
659
|
+
currentData.hasChildRecords = true;
|
|
660
|
+
} else {
|
|
661
|
+
currentData.hasChildRecords = false;
|
|
662
|
+
}
|
|
663
|
+
if ((!isNullOrUndefined(childMapping) && !shouldCount) ||
|
|
664
|
+
(hasChildMapping) && shouldCount) {
|
|
665
|
+
if (this.parent.enableCollapseAll || !isNullOrUndefined(this.parent.dataStateChange)
|
|
666
|
+
&& isNullOrUndefined(childMapping)) {
|
|
667
|
+
currentData.expanded = false;
|
|
668
|
+
} else {
|
|
669
|
+
currentData.expanded = !isNullOrUndefined(currentData[this.parent.expandStateMapping])
|
|
670
|
+
? currentData[this.parent.expandStateMapping] : true;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
if (!Object.prototype.hasOwnProperty.call(currentData, 'index')) {
|
|
674
|
+
currentData.index = currentData.hasChildRecords ? this.storedIndex : this.storedIndex;
|
|
675
|
+
}
|
|
676
|
+
if (this.isSelfReference && isNullOrUndefined(currentData[this.parent.parentIdMapping])) {
|
|
677
|
+
this.parent.parentData.push(currentData);
|
|
678
|
+
}
|
|
679
|
+
currentData.uniqueID = getUid(this.parent.element.id + '_data_');
|
|
680
|
+
setValue('uniqueIDCollection.' + currentData.uniqueID, currentData, this.parent);
|
|
681
|
+
if (!isNullOrUndefined(parentRecords)) {
|
|
682
|
+
const parentData: ITreeData = extend({}, parentRecords);
|
|
683
|
+
delete parentData.childRecords;
|
|
684
|
+
delete parentData[this.parent.childMapping];
|
|
685
|
+
if (this.isSelfReference) {
|
|
686
|
+
delete parentData.taskData[this.parent.childMapping];
|
|
687
|
+
}
|
|
688
|
+
currentData.parentItem = parentData;
|
|
689
|
+
currentData.parentUniqueID = parentData.uniqueID;
|
|
690
|
+
level = parentRecords.level + 1;
|
|
691
|
+
}
|
|
692
|
+
if (!Object.prototype.hasOwnProperty.call(currentData, 'level')) {
|
|
693
|
+
currentData.level = level;
|
|
694
|
+
}
|
|
695
|
+
currentData.checkboxState = 'uncheck';
|
|
696
|
+
const remoteCollapsedData: string = 'remoteCollapsedData';
|
|
697
|
+
if (this.parent.enableVirtualization && !this.parent.loadChildOnDemand && isRemoteData(this.parent)
|
|
698
|
+
&& !this.parent.initialRender){
|
|
699
|
+
if (!currentData.hasChildRecords && isNullOrUndefined(currentData[`${this.parent.parentIdMapping}`])) {
|
|
700
|
+
currentData.hasChildRecords = true;
|
|
701
|
+
for (let c: number = 0; c < this.parent[`${remoteCollapsedData}`].length; c++) {
|
|
702
|
+
if (this.parent[`${remoteCollapsedData}`][parseInt(c.toString(), 10)][`${this.parent.idMapping}`] === currentData[`${this.parent.idMapping}`]) {
|
|
703
|
+
currentData.expanded = false;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
else if (currentData.level === 0 && isNullOrUndefined(parentRecords) && !currentData.hasChildRecords) {
|
|
708
|
+
currentData.level = currentData.level + 1;
|
|
709
|
+
}
|
|
710
|
+
if (currentData[`${this.parent.hasChildMapping}`] && !isNullOrUndefined(currentData[`${this.parent.expandStateMapping}`])) {
|
|
711
|
+
currentData.expanded = currentData[`${this.parent.expandStateMapping}`];
|
|
712
|
+
currentData.hasChildRecords = true;
|
|
713
|
+
}
|
|
714
|
+
this.parent.flatData.push(currentData);
|
|
715
|
+
}
|
|
716
|
+
else if (isNullOrUndefined(currentData[`${this.parent.parentIdMapping}`]) || currentData.parentItem) {
|
|
717
|
+
if (!isNullOrUndefined(this.parent.rowDropSettings.targetID)) {
|
|
718
|
+
if (!this.parent.rowDragAndDropModule['isDuplicateData'](currentData)) {
|
|
719
|
+
this.parent.flatData.push(currentData);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
else {
|
|
723
|
+
this.parent.flatData.push(currentData);
|
|
724
|
+
}
|
|
725
|
+
this.parent['infiniteScrollData'].push(currentData);
|
|
726
|
+
}
|
|
727
|
+
if (!this.isSelfReference && currentData.level === 0) {
|
|
728
|
+
this.parent.parentData.push(currentData);
|
|
729
|
+
}
|
|
730
|
+
if (!isNullOrUndefined(currentData[this.parent.childMapping] && currentData[this.parent.childMapping].length )) {
|
|
731
|
+
const record: ITreeData[] = this.createRecords(currentData[this.parent.childMapping], currentData);
|
|
732
|
+
currentData.childRecords = record;
|
|
733
|
+
}
|
|
734
|
+
treeGridData.push(currentData);
|
|
735
|
+
}
|
|
736
|
+
return treeGridData;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Function to perform filtering/sorting action for local data
|
|
741
|
+
*
|
|
742
|
+
* @param {BeforeDataBoundArgs} args - data details to be processed before binding to grid
|
|
743
|
+
* @hidden
|
|
744
|
+
* @returns {void}
|
|
745
|
+
*/
|
|
746
|
+
public dataProcessor(args?: BeforeDataBoundArgs) : void {
|
|
747
|
+
const isExport: boolean = getObject('isExport', args); const expresults: Object = getObject('expresults', args);
|
|
748
|
+
const exportType: string = getObject('exportType', args); const isPrinting: boolean = getObject('isPrinting', args);
|
|
749
|
+
let dataObj: Object; const actionArgs: NotifyArgs = getObject('actionArgs', args);
|
|
750
|
+
let requestType: Action = getObject('requestType', args); let actionData: Object = getObject('data', args);
|
|
751
|
+
let action: string = getObject('action', args); const actionAddArgs: SaveEventArgs = actionArgs;
|
|
752
|
+
const primaryKeyColumnName: string = this.parent.getPrimaryKeyFieldNames()[0];
|
|
753
|
+
const dataValue: ITreeData = getObject('data', actionAddArgs);
|
|
754
|
+
if ((!isNullOrUndefined(actionAddArgs)) && (!isNullOrUndefined(actionAddArgs.action)) && (actionAddArgs.action === 'add')
|
|
755
|
+
&& (!isNullOrUndefined(actionAddArgs.data)) && isNullOrUndefined(actionAddArgs.data[`${primaryKeyColumnName}`])) {
|
|
756
|
+
actionAddArgs.data[`${primaryKeyColumnName}`] = args.result[actionAddArgs.index][`${primaryKeyColumnName}`];
|
|
757
|
+
dataValue.taskData[`${primaryKeyColumnName}`] = args.result[actionAddArgs.index][`${primaryKeyColumnName}`];
|
|
758
|
+
}
|
|
759
|
+
if ((!isNullOrUndefined(actionArgs) && Object.keys(actionArgs).length) || requestType === 'save') {
|
|
760
|
+
requestType = requestType ? requestType : actionArgs.requestType;
|
|
761
|
+
actionData = actionData ? actionData : getObject('data', actionArgs);
|
|
762
|
+
action = action ? action : getObject('action', actionArgs);
|
|
763
|
+
if (this.parent.editSettings.mode === 'Batch') {
|
|
764
|
+
this.batchChanges = this.parent.grid.editModule.getBatchChanges();
|
|
765
|
+
}
|
|
766
|
+
if (this.parent.isLocalData) {
|
|
767
|
+
this.updateAction(actionData, action, requestType);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
if (isExport && !isNullOrUndefined(expresults)) {
|
|
771
|
+
dataObj = expresults;
|
|
772
|
+
} else {
|
|
773
|
+
dataObj = isCountRequired(this.parent) ? getValue('result', this.parent.grid.dataSource)
|
|
774
|
+
: this.parent.grid.dataSource;
|
|
775
|
+
}
|
|
776
|
+
let results: ITreeData[] = dataObj instanceof DataManager ? (<DataManager>dataObj).dataSource.json : <ITreeData[]>dataObj;
|
|
777
|
+
let count: number = isCountRequired(this.parent) ? getValue('count', this.parent.dataSource)
|
|
778
|
+
: results.length;
|
|
779
|
+
const qry: Query = new Query(); let gridQuery: Query = getObject('query', args);
|
|
780
|
+
let filterQuery: QueryOptions[]; let searchQuery: QueryOptions[];
|
|
781
|
+
if (!isNullOrUndefined(gridQuery)) {
|
|
782
|
+
filterQuery = gridQuery.queries.filter((q: QueryOptions) => q.fn === 'onWhere');
|
|
783
|
+
searchQuery = gridQuery.queries.filter((q: QueryOptions) => q.fn === 'onSearch');
|
|
784
|
+
}
|
|
785
|
+
if ((this.parent.grid.allowFiltering && this.parent.grid.filterSettings.columns.length) ||
|
|
786
|
+
(this.parent.grid.searchSettings.key.length > 0) || (!isNullOrUndefined(gridQuery) &&
|
|
787
|
+
(filterQuery.length || searchQuery.length) && this.parent.isLocalData)) {
|
|
788
|
+
if (isNullOrUndefined(gridQuery)) {
|
|
789
|
+
gridQuery = new Query(); gridQuery = getValue('grid.renderModule.data', this.parent).filterQuery(gridQuery);
|
|
790
|
+
gridQuery = getValue('grid.renderModule.data', this.parent).searchQuery(gridQuery);
|
|
791
|
+
}
|
|
792
|
+
const fltrQuery: QueryOptions[] = gridQuery.queries.filter((q: QueryOptions) => q.fn === 'onWhere');
|
|
793
|
+
const srchQuery: QueryOptions[] = gridQuery.queries.filter((q: QueryOptions) => q.fn === 'onSearch');
|
|
794
|
+
qry.queries = fltrQuery.concat(srchQuery); const filteredData: Object = new DataManager(results).executeLocal(qry);
|
|
795
|
+
this.parent.notify('updateFilterRecs', { data: filteredData });
|
|
796
|
+
results = <ITreeData[]>this.dataResults.result; this.dataResults.result = null;
|
|
797
|
+
if (this.parent.grid.aggregates.length > 0) {
|
|
798
|
+
const query: Query = getObject('query', args);
|
|
799
|
+
if (isNullOrUndefined(gridQuery)) {
|
|
800
|
+
gridQuery = getValue('grid.renderModule.data', this.parent).aggregateQuery(new Query());
|
|
801
|
+
}
|
|
802
|
+
if (!isNullOrUndefined(query)) {
|
|
803
|
+
const summaryQuery: QueryOptions[] = query.queries.filter((q: QueryOptions) => q.fn === 'onAggregates');
|
|
804
|
+
results = this.parent.summaryModule.calculateSummaryValue(summaryQuery, results, true);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
if (this.parent.grid.aggregates.length && this.parent.grid.sortSettings.columns.length === 0
|
|
809
|
+
&& this.parent.grid.filterSettings.columns.length === 0 && !this.parent.grid.searchSettings.key.length) {
|
|
810
|
+
let gridQuery: Query = getObject('query', args);
|
|
811
|
+
if (isNullOrUndefined(gridQuery)) {
|
|
812
|
+
gridQuery = getValue('grid.renderModule.data', this.parent).aggregateQuery(new Query());
|
|
813
|
+
}
|
|
814
|
+
const summaryQuery: QueryOptions[] = gridQuery.queries.filter((q: QueryOptions) => q.fn === 'onAggregates');
|
|
815
|
+
results = this.parent.summaryModule.calculateSummaryValue(summaryQuery, this.parent.flatData, true);
|
|
816
|
+
}
|
|
817
|
+
if (this.parent.grid.sortSettings.columns.length > 0 || this.isSortAction) {
|
|
818
|
+
this.isSortAction = false;
|
|
819
|
+
const parentData: Object = this.parent.parentData;
|
|
820
|
+
const query: Query = getObject('query', args); const srtQry: Query = new Query();
|
|
821
|
+
for (let srt: number = this.parent.grid.sortSettings.columns.length - 1; srt >= 0; srt--) {
|
|
822
|
+
const getColumnByField: string = 'getColumnByField';
|
|
823
|
+
const col: GridColumnModel = this.parent.grid.renderModule.data[`${getColumnByField}`](this.parent.grid.
|
|
824
|
+
sortSettings.columns[parseInt(srt.toString(), 10)].field);
|
|
825
|
+
const compFun: Function | string = col.sortComparer && isOffline(this.parent) ?
|
|
826
|
+
(col.sortComparer as Function).bind(col) :
|
|
827
|
+
this.parent.grid.sortSettings.columns[parseInt(srt.toString(), 10)].direction;
|
|
828
|
+
srtQry.sortBy(this.parent.grid.sortSettings.columns[parseInt(srt.toString(), 10)].field, compFun);
|
|
829
|
+
}
|
|
830
|
+
const modifiedData: Object = new DataManager(parentData).executeLocal(srtQry);
|
|
831
|
+
if (this.parent.allowRowDragAndDrop && !isNullOrUndefined(this.parent.rowDragAndDropModule['draggedRecord']) &&
|
|
832
|
+
this.parent.rowDragAndDropModule['droppedRecord'].hasChildRecords && this.parent.rowDragAndDropModule['dropPosition'] !== 'middleSegment') {
|
|
833
|
+
const dragdIndex: number = (modifiedData as ITreeData[]).indexOf(this.parent.rowDragAndDropModule['draggedRecord']);
|
|
834
|
+
(modifiedData as ITreeData[]).splice(dragdIndex, 1);
|
|
835
|
+
const dropdIndex: number = (modifiedData as ITreeData[]).indexOf(this.parent.rowDragAndDropModule['droppedRecord']);
|
|
836
|
+
if (this.parent.rowDragAndDropModule['droppedRecord'].hasChildRecords && this.parent.rowDragAndDropModule['dropPosition'] === 'topSegment') {
|
|
837
|
+
(modifiedData as ITreeData[]).splice(dropdIndex, 0, this.parent.rowDragAndDropModule['draggedRecord']);
|
|
838
|
+
}
|
|
839
|
+
else if (this.parent.rowDragAndDropModule['dropPosition'] === 'bottomSegment') {
|
|
840
|
+
(modifiedData as ITreeData[]).splice(dropdIndex + 1, 0, this.parent.rowDragAndDropModule['draggedRecord']);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
const sortArgs: { modifiedData: ITreeData[], filteredData: ITreeData[], srtQry: Query}
|
|
844
|
+
= {modifiedData: <Object[]>modifiedData, filteredData: results, srtQry: srtQry};
|
|
845
|
+
this.parent.notify('createSort', sortArgs); results = sortArgs.modifiedData;
|
|
846
|
+
this.dataResults.result = null; this.sortedData = results; this.parent.notify('updateModel', {});
|
|
847
|
+
if (this.parent.grid.aggregates.length > 0 && !isNullOrUndefined(query)) {
|
|
848
|
+
const isSort: boolean = false;
|
|
849
|
+
const query: Query = getObject('query', args);
|
|
850
|
+
const summaryQuery: QueryOptions[] = query.queries.filter((q: QueryOptions) => q.fn === 'onAggregates');
|
|
851
|
+
results = this.parent.summaryModule.calculateSummaryValue(summaryQuery, this.sortedData, isSort);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
count = isCountRequired(this.parent) ? getValue('count', this.parent.dataSource)
|
|
855
|
+
: results.length;
|
|
856
|
+
const temp: BeforeDataBoundArgs = this.paging(results, count, isExport, isPrinting, exportType, args);
|
|
857
|
+
results = temp.result; count = temp.count;
|
|
858
|
+
args.result = results; args.count = count;
|
|
859
|
+
this.parent.notify('updateResults', args);
|
|
860
|
+
}
|
|
861
|
+
private paging(results: ITreeData[], count: number, isExport: boolean,
|
|
862
|
+
isPrinting: boolean, exportType: string, args: Object): BeforeDataBoundArgs {
|
|
863
|
+
if (this.parent.allowPaging && (!isExport || exportType === 'CurrentPage')
|
|
864
|
+
&& (!isPrinting || this.parent.printMode === 'CurrentPage')) {
|
|
865
|
+
this.parent.notify(events.pagingActions, {result: results, count: count, actionArgs: args});
|
|
866
|
+
results = <ITreeData[]>this.dataResults.result;
|
|
867
|
+
count = isCountRequired(this.parent) ? getValue('count', this.parent.dataSource)
|
|
868
|
+
: this.dataResults.count;
|
|
869
|
+
} else if ((this.parent.enableVirtualization || this.parent.enableInfiniteScrolling) && (!isExport || exportType === 'CurrentPage')
|
|
870
|
+
&& getValue('requestType', args) !== 'save') {
|
|
871
|
+
const actArgs: Object = this.parent.enableInfiniteScrolling ? args : getValue('actionArgs', args);
|
|
872
|
+
this.parent.notify(events.pagingActions, {result: results, count: count, actionArgs: actArgs});
|
|
873
|
+
results = <ITreeData[]>this.dataResults.result;
|
|
874
|
+
count = this.dataResults.count;
|
|
875
|
+
}
|
|
876
|
+
const isPdfExport: string = 'isPdfExport'; const isCollapsedStatePersist: string = 'isCollapsedStatePersist';
|
|
877
|
+
if ((isPrinting === true || (args[`${isPdfExport}`] && (isNullOrUndefined(args[`${isCollapsedStatePersist}`])
|
|
878
|
+
|| args[`${isCollapsedStatePersist}`]))) && this.parent.printMode === 'AllPages') {
|
|
879
|
+
const actualResults: ITreeData[] = [];
|
|
880
|
+
for (let i: number = 0; i < results.length; i++) {
|
|
881
|
+
const expandStatus: boolean = getExpandStatus(this.parent, results[parseInt(i.toString(), 10)], this.parent.parentData);
|
|
882
|
+
if (expandStatus) {
|
|
883
|
+
actualResults.push(results[parseInt(i.toString(), 10)]);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
results = actualResults;
|
|
887
|
+
count = results.length;
|
|
888
|
+
}
|
|
889
|
+
const value: BeforeDataBoundArgs = { result: results, count: count };
|
|
890
|
+
return value;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
private updateData(dataResult: {result: ITreeData, count: number}): void {
|
|
894
|
+
this.dataResults = <ReturnOption>dataResult;
|
|
895
|
+
}
|
|
896
|
+
private updateAction(actionData: ITreeData, action: string, requestType: string): void {
|
|
897
|
+
if ((requestType === 'delete' || requestType === 'save')) {
|
|
898
|
+
this.parent.notify(events.crudAction, { value: actionData, action: action || requestType });
|
|
899
|
+
}
|
|
900
|
+
if (requestType === 'batchsave' && this.parent.editSettings.mode === 'Batch') {
|
|
901
|
+
this.parent.notify(events.batchSave, {});
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}
|