@refinitiv-ui/efx-grid 6.0.107 → 6.0.109
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/core/dist/core.js +133 -56
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/grid/Core.d.ts +2 -2
- package/lib/core/es6/grid/Core.js +132 -55
- package/lib/core/es6/grid/components/Scrollbar.js +1 -1
- package/lib/formatters/es6/index.d.ts +22 -1
- package/lib/formatters/es6/index.js +22 -1
- package/lib/grid/index.js +1 -1
- package/lib/grid/lib/efx-grid.js +32 -10
- package/lib/rt-grid/dist/rt-grid.js +286 -149
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.js +126 -90
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +1452 -1304
- package/lib/tr-grid-filter-input/es6/FilterInput.d.ts +2 -0
- package/lib/tr-grid-filter-input/es6/FilterInput.js +19 -0
- package/lib/tr-grid-row-filtering/es6/RowFiltering.d.ts +4 -0
- package/lib/tr-grid-row-filtering/es6/RowFiltering.js +36 -1
- package/lib/tr-grid-util/es6/GroupDefinitions.js +3 -3
- package/lib/types/es6/Core/grid/Core.d.ts +2 -2
- package/lib/types/es6/FilterInput.d.ts +2 -0
- package/lib/types/es6/RowFiltering.d.ts +6 -0
- package/lib/versions.json +5 -5
- package/package.json +1 -1
@@ -25,22 +25,23 @@ import { cloneObject, injectCss, prettifyCss, deepEqual } from "../../tr-grid-ut
|
|
25
25
|
* @extends {GridPlugin}
|
26
26
|
* @param {ColumnGroupingPlugin~Options=} options
|
27
27
|
*/
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
28
|
+
let ColumnGroupingPlugin = function (options) {
|
29
|
+
let t = this;
|
30
|
+
t._hosts = [];
|
31
|
+
|
32
|
+
t._onColumnChanged = t._onColumnChanged.bind(t);
|
33
|
+
t._onColumnAdded = t._onColumnAdded.bind(t);
|
34
|
+
t._onColumnMoved = t._onColumnMoved.bind(t);
|
35
|
+
t._onColumnRemoved = t._onColumnRemoved.bind(t);
|
36
|
+
t._requestApplyAddChildGroup = t._requestApplyAddChildGroup.bind(this);
|
37
|
+
t._onPostSectionRender = t._onPostSectionRender.bind(t);
|
38
|
+
t._onBeforeColumnBoundUpdate = t._onBeforeColumnBoundUpdate.bind(t);
|
39
|
+
|
40
|
+
t._groupDefs = new GroupDefinitions();
|
41
|
+
|
42
|
+
if(options) {
|
43
|
+
t.config({ "columnGrouping": options });
|
44
|
+
}
|
44
45
|
};
|
45
46
|
Ext.inherits(ColumnGroupingPlugin, GridPlugin);
|
46
47
|
|
@@ -93,39 +94,39 @@ ColumnGroupingPlugin.prototype._selectedColMap;
|
|
93
94
|
* @param {number} b
|
94
95
|
* @return {number}
|
95
96
|
*/
|
96
|
-
ColumnGroupingPlugin._ascSortLogic = function
|
97
|
-
|
97
|
+
ColumnGroupingPlugin._ascSortLogic = function(a, b) {
|
98
|
+
return a - b;
|
98
99
|
};
|
99
100
|
/** @private
|
100
101
|
* @param {ColumnGroupingPlugin~GroupDefinition} groupingOptions
|
101
102
|
* @return {string}
|
102
103
|
*/
|
103
|
-
ColumnGroupingPlugin._getTooltip = function
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
104
|
+
ColumnGroupingPlugin._getTooltip = function(groupingOptions) {
|
105
|
+
let tooltip = groupingOptions["tooltip"];
|
106
|
+
let title = groupingOptions["title"] || groupingOptions["name"];
|
107
|
+
if(tooltip != null) {
|
108
|
+
if(typeof tooltip === "string") {
|
109
|
+
return tooltip; // There is a custom tooltip
|
110
|
+
} else if(tooltip === true) {
|
111
|
+
return title;
|
112
|
+
} else if(tooltip === false) {
|
113
|
+
return "";
|
114
|
+
}
|
115
|
+
}
|
116
|
+
return title;
|
116
117
|
};
|
117
118
|
/** @private
|
118
119
|
* @function
|
119
120
|
* @param {Object} groupDef
|
120
121
|
* @return {boolean}
|
121
122
|
*/
|
122
|
-
ColumnGroupingPlugin._hasGroupId = function
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
123
|
+
ColumnGroupingPlugin._hasGroupId = function(groupDef) {
|
124
|
+
if(groupDef) {
|
125
|
+
if(groupDef.id) {
|
126
|
+
return true;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
return false;
|
129
130
|
};
|
130
131
|
|
131
132
|
/** @private
|
@@ -134,47 +135,47 @@ ColumnGroupingPlugin._hasGroupId = function (groupDef) {
|
|
134
135
|
* @param {string=} groupId
|
135
136
|
* @return {ColumnGroupingPlugin~GroupDefinition}
|
136
137
|
*/
|
137
|
-
ColumnGroupingPlugin._toGroupDefinition = function
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
138
|
+
ColumnGroupingPlugin._toGroupDefinition = function(obj, groupId) {
|
139
|
+
let groupDef = null;
|
140
|
+
if(obj) {
|
141
|
+
if(Array.isArray(obj)) {
|
142
|
+
groupDef = {
|
143
|
+
children: obj
|
144
|
+
};
|
145
|
+
} else {
|
146
|
+
groupDef = ColumnGroupingPlugin._cloneObject(obj);
|
147
|
+
}
|
148
|
+
if(groupId) {
|
149
|
+
if(!groupDef.id) {
|
150
|
+
groupDef.name = groupId;
|
151
|
+
}
|
152
|
+
groupDef.id = groupId;
|
153
|
+
}
|
154
|
+
}
|
155
|
+
return groupDef;
|
155
156
|
};
|
156
157
|
/** @private
|
157
158
|
* @function
|
158
159
|
* @param {Object} obj
|
159
160
|
* @return {Object}
|
160
161
|
*/
|
161
|
-
ColumnGroupingPlugin._cloneObject = function
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
162
|
+
ColumnGroupingPlugin._cloneObject = function(obj) {
|
163
|
+
let newObj = cloneObject(obj);
|
164
|
+
if(!Array.isArray(newObj.children)) {
|
165
|
+
newObj.children = [];
|
166
|
+
}
|
167
|
+
return newObj;
|
167
168
|
};
|
168
169
|
/** Flatten tree structure to simple dictionary
|
169
170
|
* @private
|
170
171
|
* @function
|
171
172
|
* @param {ColumnGroupingPlugin~GroupDefinitions} groupDefs
|
172
173
|
*/
|
173
|
-
ColumnGroupingPlugin._flattenGroupDefs = function
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
174
|
+
ColumnGroupingPlugin._flattenGroupDefs = function(groupDefs) {
|
175
|
+
let grpCount = groupDefs ? groupDefs.length : 0;
|
176
|
+
for(let i = 0; i < grpCount; i++) {
|
177
|
+
ColumnGroupingPlugin._recursivelyFlatten(groupDefs[i], groupDefs);
|
178
|
+
}
|
178
179
|
};
|
179
180
|
/** Flatten group definition structure by using group ID instead of nested group definitions.
|
180
181
|
* @private
|
@@ -183,24 +184,23 @@ ColumnGroupingPlugin._flattenGroupDefs = function (groupDefs) {
|
|
183
184
|
* @param {Array} groupDefs
|
184
185
|
*/
|
185
186
|
ColumnGroupingPlugin._recursivelyFlatten = function (groupDef, groupDefs) {
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
}
|
187
|
+
if(groupDef && groupDef.children) {
|
188
|
+
let children = groupDef.children;
|
189
|
+
let member, groupId;
|
190
|
+
for(let i = 0; i < children.length; i++) {
|
191
|
+
member = children[i];
|
192
|
+
if(typeof member !== "string") { // member is nested group definition
|
193
|
+
groupId = member.id;
|
194
|
+
if(groupId) {
|
195
|
+
children[i] = groupId; // Use group ID instead of nested group definition
|
196
|
+
if(groupDefs.indexOf(member) < 0) {
|
197
|
+
groupDefs.push(member);
|
198
|
+
}
|
199
|
+
ColumnGroupingPlugin._recursivelyFlatten(member, groupDefs);
|
200
|
+
}
|
201
|
+
} // TODO: Invalid group is not flatten
|
202
|
+
}
|
203
|
+
}
|
204
204
|
};
|
205
205
|
|
206
206
|
/** Filter time series group out
|
@@ -209,21 +209,21 @@ ColumnGroupingPlugin._recursivelyFlatten = function (groupDef, groupDefs) {
|
|
209
209
|
* @return {boolean}
|
210
210
|
*/
|
211
211
|
ColumnGroupingPlugin._isNotTimeSeriesGroup = function (groupDef) {
|
212
|
-
|
212
|
+
return groupDef.timeSeriesGroup ? false : true;
|
213
213
|
};
|
214
214
|
|
215
215
|
/** @public
|
216
216
|
* @return {string}
|
217
217
|
*/
|
218
218
|
ColumnGroupingPlugin.prototype.getName = function () {
|
219
|
-
|
219
|
+
return "ColumnGroupingPlugin"; // Read Only
|
220
220
|
};
|
221
221
|
/**
|
222
222
|
* @override
|
223
223
|
* @return {boolean}
|
224
224
|
*/
|
225
|
-
ColumnGroupingPlugin.prototype.hasMultiTableSupport = function
|
226
|
-
|
225
|
+
ColumnGroupingPlugin.prototype.hasMultiTableSupport = function() {
|
226
|
+
return true;
|
227
227
|
};
|
228
228
|
|
229
229
|
/** @public
|
@@ -231,37 +231,43 @@ ColumnGroupingPlugin.prototype.hasMultiTableSupport = function () {
|
|
231
231
|
* @param {Object=} options
|
232
232
|
*/
|
233
233
|
ColumnGroupingPlugin.prototype.initialize = function (host, options) {
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
234
|
+
if(this._hosts.indexOf(host) >= 0) { return; }
|
235
|
+
this._hosts.push(host);
|
236
|
+
if(typeof host.setColumnGrouping === "function") {
|
237
|
+
host.setColumnGrouping(this._groupDefs);
|
238
|
+
}
|
239
|
+
|
240
|
+
if(!this._addingEvents) {
|
241
|
+
this._addingEvents = [];
|
242
|
+
}
|
243
|
+
|
244
|
+
if(this._hosts.length === 1) {
|
245
|
+
host.listen("columnAdded", this._onColumnAdded);
|
246
|
+
host.listen("columnMoved", this._onColumnMoved);
|
247
|
+
host.listen("columnRemoved", this._onColumnRemoved);
|
248
|
+
host.listen("columnVisibilityChanged", this._onColumnChanged);
|
249
|
+
host.listen("postSectionRender", this._onPostSectionRender);
|
250
|
+
host.listen("beforeColumnBoundUpdate", this._onBeforeColumnBoundUpdate);
|
251
|
+
}
|
252
|
+
this.config(options);
|
253
|
+
this._legacyColumnGroups = null;
|
254
|
+
|
255
|
+
if(this._initializedGrid && host.getSection("title")) { // For run-time loading
|
256
|
+
this._applyGrouping();
|
257
|
+
}
|
258
|
+
|
259
|
+
if(!ColumnGroupingPlugin._styles) {
|
260
|
+
ColumnGroupingPlugin._styles = prettifyCss([
|
261
|
+
".tr-grid .title .column .cell:not(:last-child)", [
|
262
|
+
"box-shadow: none;"
|
263
|
+
]
|
264
|
+
]);
|
265
|
+
}
|
266
|
+
|
267
|
+
if(!host._columnGroupingStyles){
|
268
|
+
host._columnGroupingStyles = true;
|
269
|
+
injectCss(ColumnGroupingPlugin._styles, host.getElement());
|
270
|
+
}
|
265
271
|
};
|
266
272
|
/** Prevent built-in config
|
267
273
|
* @public
|
@@ -270,90 +276,92 @@ ColumnGroupingPlugin.prototype.initialize = function (host, options) {
|
|
270
276
|
* @return {*}
|
271
277
|
*/
|
272
278
|
ColumnGroupingPlugin.prototype.beforeProcessOption = function (optionName, optionValue) {
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
return; // eslint-disable-line
|
279
|
+
if(optionName === "columnGroups") {
|
280
|
+
this._legacyColumnGroups = optionValue;
|
281
|
+
return false; // eslint-disable-line
|
282
|
+
}
|
283
|
+
return; // eslint-disable-line
|
279
284
|
};
|
280
285
|
/**
|
281
286
|
* @protected
|
282
287
|
* @ignore
|
283
288
|
*/
|
284
|
-
ColumnGroupingPlugin.prototype._afterInit = function
|
285
|
-
|
289
|
+
ColumnGroupingPlugin.prototype._afterInit = function() {
|
290
|
+
this._applyGrouping();
|
286
291
|
};
|
287
292
|
/** @public
|
288
293
|
* @param {Object} host core grid object
|
289
294
|
*/
|
290
295
|
ColumnGroupingPlugin.prototype.unload = function (host) {
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
296
|
+
let at = this._hosts.indexOf(host);
|
297
|
+
if(at < 0) { return; }
|
298
|
+
this._hosts.splice(at, 1);
|
299
|
+
if(typeof host.setColumnGrouping === "function") {
|
300
|
+
host.setColumnGrouping(null);
|
301
|
+
}
|
302
|
+
|
303
|
+
host.unlisten("columnAdded", this._onColumnChanged);
|
304
|
+
host.unlisten("columnMoved", this._onColumnMoved);
|
305
|
+
host.unlisten("columnRemoved", this._onColumnRemoved);
|
306
|
+
host.unlisten("postSectionRender", this._onPostSectionRender);
|
307
|
+
host.unlisten("beforeColumnBoundUpdate", this._onBeforeColumnBoundUpdate);
|
308
|
+
|
309
|
+
if(!this._hosts.length) {
|
310
|
+
if(this._rerenderTimerId){
|
311
|
+
clearTimeout(this._rerenderTimerId);
|
312
|
+
this._rerenderTimerId = 0;
|
313
|
+
}
|
314
|
+
if(this._groupHeaderTimerId){
|
315
|
+
clearTimeout(this._groupHeaderTimerId);
|
316
|
+
this._groupHeaderTimerId = 0;
|
317
|
+
}
|
318
|
+
if(this._addingTimerId) {
|
319
|
+
clearTimeout(this._addingTimerId);
|
320
|
+
this._addingTimerId = 0;
|
321
|
+
this._addingEvents.length = 0;
|
322
|
+
}
|
323
|
+
}
|
324
|
+
|
325
|
+
this._dispose();
|
320
326
|
};
|
321
327
|
/** @public
|
322
328
|
* @param {Object} options
|
323
329
|
*/
|
324
330
|
ColumnGroupingPlugin.prototype.config = function (options) {
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
331
|
+
if(!options) { return; }
|
332
|
+
|
333
|
+
let extOptions = options["columnGrouping"];
|
334
|
+
let groupDefs = null;
|
335
|
+
if(Array.isArray(extOptions)) {
|
336
|
+
groupDefs = extOptions.filter(ColumnGroupingPlugin._hasGroupId);
|
337
|
+
groupDefs = groupDefs.map(ColumnGroupingPlugin._cloneObject);
|
338
|
+
}
|
339
|
+
|
340
|
+
let columns = options["columns"];
|
341
|
+
if(columns) {
|
342
|
+
groupDefs = this._migrateLegacyStructure(groupDefs, columns);
|
343
|
+
}
|
344
|
+
|
345
|
+
if(groupDefs) {
|
346
|
+
ColumnGroupingPlugin._flattenGroupDefs(groupDefs);
|
347
|
+
this._groupDefs.setGroups(groupDefs);
|
348
|
+
}
|
342
349
|
};
|
343
350
|
/** @public
|
344
351
|
* @param {Object=} gridOptions
|
345
352
|
* @return {!Object}
|
346
353
|
*/
|
347
354
|
ColumnGroupingPlugin.prototype.getConfigObject = function (gridOptions) {
|
348
|
-
|
355
|
+
let obj = gridOptions || {};
|
349
356
|
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
+
// TODO: Handle legacyRender method that has been migrated
|
358
|
+
let groupDefs = this.getGroupDefinitions();
|
359
|
+
groupDefs = groupDefs.filter(ColumnGroupingPlugin._isNotTimeSeriesGroup);
|
360
|
+
if(groupDefs.length) {
|
361
|
+
obj.columnGrouping = groupDefs;
|
362
|
+
}
|
363
|
+
|
364
|
+
return obj;
|
357
365
|
};
|
358
366
|
|
359
367
|
/** @private
|
@@ -363,15 +371,15 @@ ColumnGroupingPlugin.prototype.getConfigObject = function (gridOptions) {
|
|
363
371
|
* @return {boolean} Returns true if there is any change
|
364
372
|
*/
|
365
373
|
ColumnGroupingPlugin._mapParentToChildren = function (objMap, parentId, childId) {
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
374
|
+
if(parentId && childId) {
|
375
|
+
let ary = objMap[parentId];
|
376
|
+
if(!ary) {
|
377
|
+
ary = objMap[parentId] = [];
|
378
|
+
}
|
379
|
+
ary.push(childId);
|
380
|
+
return true;
|
381
|
+
}
|
382
|
+
return false;
|
375
383
|
};
|
376
384
|
/** Legacy group structure from composite grid will be converted to the new structure
|
377
385
|
* @private
|
@@ -380,169 +388,184 @@ ColumnGroupingPlugin._mapParentToChildren = function (objMap, parentId, childId)
|
|
380
388
|
* @return {ColumnGroupingPlugin~GroupDefinitions}
|
381
389
|
*/
|
382
390
|
ColumnGroupingPlugin.prototype._migrateLegacyStructure = function (groupDefs, colModels) {
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
391
|
+
let legacyColumnGroups = this._legacyColumnGroups;
|
392
|
+
if(!legacyColumnGroups || !this._compositeGrid) {
|
393
|
+
return groupDefs;
|
394
|
+
}
|
395
|
+
if(!groupDefs) {
|
396
|
+
groupDefs = [];
|
397
|
+
}
|
398
|
+
|
399
|
+
// Collecting parent groups from col models (leaf node)
|
400
|
+
let colCount = colModels.length;
|
401
|
+
let groupMap = {}; // Parent-children pair map
|
402
|
+
for(let c = 0; c < colCount; ++c) {
|
403
|
+
let colModel = colModels[c];
|
404
|
+
if(colModel) {
|
405
|
+
ColumnGroupingPlugin._mapParentToChildren(
|
406
|
+
groupMap, colModel.columnGroup, colModel.id
|
407
|
+
);
|
408
|
+
}
|
409
|
+
}
|
410
|
+
// Collecting parent groups from the group list (groups can have parent as well)
|
411
|
+
let groupCount = legacyColumnGroups.length;
|
412
|
+
let i, groupDef;
|
413
|
+
for(i = 0; i < groupCount; ++i) {
|
414
|
+
groupDef = legacyColumnGroups[i];
|
415
|
+
if(groupDef) {
|
416
|
+
ColumnGroupingPlugin._mapParentToChildren(
|
417
|
+
groupMap, groupDef.parent, groupDef.id
|
418
|
+
);
|
419
|
+
}
|
420
|
+
}
|
421
|
+
// TODO: Merge child relationship to existing group structure
|
422
|
+
|
423
|
+
// Add new definitions and structure to the given legacy objects
|
424
|
+
for(i = 0; i < groupCount; ++i) {
|
425
|
+
groupDef = ColumnGroupingPlugin._cloneObject(legacyColumnGroups[i]);
|
426
|
+
if(groupDef && groupDef.id) {
|
427
|
+
// WARNING: Modify user's object
|
428
|
+
let childAry = groupMap[groupDef.id];
|
429
|
+
groupDef.children = childAry ? childAry : [];
|
430
|
+
|
431
|
+
if(groupDef["formatter"] && groupDef["formatter"]["render"]) {
|
432
|
+
groupDef["legacyRender"] = groupDef["formatter"]["render"];
|
433
|
+
delete groupDef["formatter"];
|
434
|
+
}
|
435
|
+
|
436
|
+
groupDefs.push(groupDef);
|
437
|
+
}
|
438
|
+
}
|
439
|
+
|
440
|
+
return groupDefs.filter(ColumnGroupingPlugin._hasGroupId);
|
426
441
|
};
|
427
442
|
/** @private
|
428
443
|
* @param {number} frozenColIndex
|
429
444
|
* @param {number=} numRightColumn
|
430
445
|
*/
|
431
|
-
ColumnGroupingPlugin.prototype._freezeColumn = function
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
446
|
+
ColumnGroupingPlugin.prototype._freezeColumn = function(frozenColIndex, numRightColumn) {
|
447
|
+
let hosts = this._hosts;
|
448
|
+
for(let i = 0; i < hosts.length; i++) {
|
449
|
+
hosts[i].freezeColumn(frozenColIndex, numRightColumn);
|
450
|
+
}
|
436
451
|
};
|
437
452
|
/** @private
|
438
453
|
*/
|
439
|
-
ColumnGroupingPlugin.prototype._applyPinning = function
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
454
|
+
ColumnGroupingPlugin.prototype._applyPinning = function() {
|
455
|
+
let colCount = this.getColumnCount();
|
456
|
+
let columnIds = this.getColumnIds();
|
457
|
+
let leftPinnedIndex = this._hosts[0].getFrozenColumnCount() - 1;
|
458
|
+
let rightPinnedIndex = this._hosts[0].getFirstPinnedRightIndex();
|
459
|
+
let i, groupId, groupDef;
|
460
|
+
let dirty = false;
|
461
|
+
for(i = colCount; i > leftPinnedIndex; i--) {
|
462
|
+
groupId = this._groupDefs.getParentId(columnIds[i]);
|
463
|
+
groupDef = this._visibleGroupMap[groupId];
|
464
|
+
if(groupDef && groupDef.leftPinned) {
|
465
|
+
leftPinnedIndex = i;
|
466
|
+
dirty = true;
|
467
|
+
break;
|
468
|
+
}
|
469
|
+
}
|
470
|
+
|
471
|
+
for(i = leftPinnedIndex; i < rightPinnedIndex; i++) {
|
472
|
+
groupId = this._groupDefs.getParentId(columnIds[i]);
|
473
|
+
groupDef = this._visibleGroupMap[groupId];
|
474
|
+
if(groupDef && groupDef.rightPinned) {
|
475
|
+
rightPinnedIndex = i;
|
476
|
+
dirty = true;
|
477
|
+
break;
|
478
|
+
}
|
479
|
+
}
|
480
|
+
if(dirty) {
|
481
|
+
let rightPinnedCount = colCount - rightPinnedIndex;
|
482
|
+
this._freezeColumn(leftPinnedIndex, rightPinnedCount);
|
483
|
+
}
|
468
484
|
};
|
469
485
|
/** Consolidate and process configuration. Force rerendering on column adding, removing, moving, initializaing, and run-time API execution.
|
470
486
|
* @private
|
471
487
|
*/
|
472
488
|
ColumnGroupingPlugin.prototype._applyGrouping = function () {
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
489
|
+
this._rerenderTimerId = 0;
|
490
|
+
if(this._restructuring) {
|
491
|
+
return;
|
492
|
+
}
|
493
|
+
this._restructuring = true;
|
494
|
+
|
495
|
+
this._evaluateGroupStructure();
|
496
|
+
|
497
|
+
// Apply column pinning
|
498
|
+
this._applyPinning();
|
499
|
+
|
500
|
+
let i, c, r, cell, section, colCount;
|
501
|
+
let rowCount = this._maxDepth + 1;
|
502
|
+
let hostCount = this._hosts.length;
|
503
|
+
for(i = hostCount; --i >= 0;) {
|
504
|
+
section = this._hosts[i].getSection("title");
|
505
|
+
if(section) {
|
506
|
+
section.setRowCount(rowCount); // This will cause postSectionRender event to be fired
|
507
|
+
section.clearCellSpans();
|
508
|
+
|
509
|
+
// Remove additional cell settings from _renderGroups() method
|
510
|
+
colCount = section.getColumnCount();
|
511
|
+
for(c = 0; c < colCount; c++) {
|
512
|
+
for(r = 0; r < rowCount; r++) {
|
513
|
+
cell = section.getCell(c, r, false);
|
514
|
+
if(cell) {
|
515
|
+
// TODO: The style and class from the user will not be reset, for example, the color or background
|
516
|
+
cell.removeClass("no-sort");
|
517
|
+
cell.removeClass("selected-group");
|
518
|
+
cell.removeAttribute("group-id");
|
519
|
+
}
|
520
|
+
}
|
521
|
+
}
|
522
|
+
|
523
|
+
this._spanGroupVertically(section);
|
524
|
+
// TODO: Some calculation in here should not be done in this loop
|
525
|
+
this._spanGroupHorizontally(section);
|
526
|
+
}
|
527
|
+
}
|
528
|
+
|
529
|
+
this._restructuring = false;
|
530
|
+
|
531
|
+
// Request re-rendering
|
532
|
+
for(i = hostCount; --i >= 0;) {
|
533
|
+
let settings = this._hosts[i].getSectionSettings("title");
|
534
|
+
if(settings) {
|
535
|
+
settings.rerender();
|
536
|
+
}
|
537
|
+
}
|
518
538
|
};
|
519
539
|
|
520
540
|
/** @private
|
521
541
|
*/
|
522
542
|
ColumnGroupingPlugin.prototype._evaluateGroupStructure = function () {
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
543
|
+
// Clone group definitions for rendering
|
544
|
+
let visibleGroupMap = this._visibleGroupMap = this._groupDefs.cloneGroupMap();
|
545
|
+
|
546
|
+
this._verifySingleChild(visibleGroupMap);
|
547
|
+
this._verifyColumnPinning(visibleGroupMap);
|
548
|
+
|
549
|
+
// Update depth (onRow) and parentId
|
550
|
+
let maxDepth = this._maxDepth = -1;
|
551
|
+
for(let groupId in visibleGroupMap) {
|
552
|
+
let groupDef = visibleGroupMap[groupId];
|
553
|
+
|
554
|
+
let parentId = groupDef.parentId;
|
555
|
+
if(parentId) {
|
556
|
+
if(!visibleGroupMap[parentId]) {
|
557
|
+
groupDef.parentId = ""; // Parent has been removed from visible view
|
558
|
+
}
|
559
|
+
}
|
560
|
+
|
561
|
+
let depth = GroupDefinitions.calcTreeDepth(visibleGroupMap, groupDef);
|
562
|
+
groupDef["onRow"] = depth;
|
563
|
+
if(depth > maxDepth) {
|
564
|
+
maxDepth = depth;
|
565
|
+
}
|
566
|
+
}
|
567
|
+
|
568
|
+
this._maxDepth = maxDepth + 1; // Column header depth = maximum group depth + 1
|
546
569
|
};
|
547
570
|
|
548
571
|
/** Add pinning state to group definition for further verification.
|
@@ -550,561 +573,606 @@ ColumnGroupingPlugin.prototype._evaluateGroupStructure = function () {
|
|
550
573
|
* @param {Object} groupDef
|
551
574
|
* @param {string} side
|
552
575
|
*/
|
553
|
-
ColumnGroupingPlugin.prototype._setGroupPinning = function
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
576
|
+
ColumnGroupingPlugin.prototype._setGroupPinning = function(groupDef, side) {
|
577
|
+
if(!groupDef || groupDef.leftPinned || groupDef.rightPinned) {
|
578
|
+
return;
|
579
|
+
}
|
580
|
+
|
581
|
+
if(side === "left") {
|
582
|
+
groupDef.leftPinned = true;
|
583
|
+
} else {
|
584
|
+
groupDef.rightPinned = true;
|
585
|
+
}
|
586
|
+
|
587
|
+
let children = groupDef["children"];
|
588
|
+
for(let i = 0; i < children.length; i++){
|
589
|
+
let child = children[i];
|
590
|
+
let group = this._visibleGroupMap[child];
|
591
|
+
if(group) {
|
592
|
+
this._setGroupPinning(group, side);
|
593
|
+
}
|
594
|
+
}
|
570
595
|
};
|
571
596
|
|
572
597
|
/** @private
|
573
598
|
* @param {Object} groupMap
|
574
599
|
*/
|
575
|
-
ColumnGroupingPlugin.prototype._verifyColumnPinning = function
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
600
|
+
ColumnGroupingPlugin.prototype._verifyColumnPinning = function(groupMap) {
|
601
|
+
let host = this._hosts[0];
|
602
|
+
let leftPinnedIndex = host.getFrozenColumnCount() - 1;
|
603
|
+
let rightPinnedIndex = host.getFirstPinnedRightIndex();
|
604
|
+
let colCount = this.getColumnCount();
|
605
|
+
|
606
|
+
let i, groupId, rootGroup, colId;
|
607
|
+
let groupDefs = this._groupDefs;
|
608
|
+
let visibleGroupMap = this._visibleGroupMap;
|
609
|
+
if(leftPinnedIndex >= 0) {
|
610
|
+
for(i = leftPinnedIndex; i >= 0; i--) {
|
611
|
+
colId = this.getColumnId(i);
|
612
|
+
groupId = groupDefs.getParentId(colId);
|
613
|
+
if(groupId && visibleGroupMap[groupId]) {
|
614
|
+
rootGroup = groupDefs.getRootGroup(groupId);
|
615
|
+
if(rootGroup) {
|
616
|
+
this._setGroupPinning(visibleGroupMap[rootGroup["id"]], "left");
|
617
|
+
}
|
618
|
+
}
|
619
|
+
}
|
620
|
+
}
|
621
|
+
|
622
|
+
if(rightPinnedIndex < colCount) {
|
623
|
+
for(i = rightPinnedIndex; i < colCount; i++) {
|
624
|
+
colId = this.getColumnId(i);
|
625
|
+
groupId = groupDefs.getParentId(colId);
|
626
|
+
if(groupId && visibleGroupMap[groupId]) {
|
627
|
+
rootGroup = groupDefs.getRootGroup(groupId);
|
628
|
+
if(rootGroup) {
|
629
|
+
this._setGroupPinning(visibleGroupMap[rootGroup["id"]], "right");
|
630
|
+
}
|
631
|
+
}
|
632
|
+
}
|
633
|
+
}
|
607
634
|
};
|
608
635
|
/** @private
|
609
636
|
* @param {Object} groupMap
|
610
637
|
*/
|
611
|
-
ColumnGroupingPlugin.prototype._verifySingleChild = function
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
638
|
+
ColumnGroupingPlugin.prototype._verifySingleChild = function(groupMap) {
|
639
|
+
let api = this.getGridApi();
|
640
|
+
if(!api) {
|
641
|
+
return;
|
642
|
+
}
|
643
|
+
let core = this._hosts[0];
|
644
|
+
let colCount = this.getColumnCount();
|
645
|
+
let validIds = {};
|
646
|
+
|
647
|
+
let i, j;
|
648
|
+
// initialize a map for all valid and hidden ids of groups and columns
|
649
|
+
for(i = 0; i < colCount; i++){
|
650
|
+
let colId = this.getColumnId(i);
|
651
|
+
if(colId){
|
652
|
+
if(core.isColumnVisible(i)){
|
653
|
+
validIds[colId] = 1;
|
654
|
+
}
|
655
|
+
}
|
656
|
+
}
|
657
|
+
|
658
|
+
let groupIds = Object.keys(groupMap);
|
659
|
+
let groupCount = groupIds.length;
|
660
|
+
for(i = 0; i < groupCount; i++){
|
661
|
+
validIds[groupIds[i]] = 1;
|
662
|
+
}
|
663
|
+
|
664
|
+
let removable = true;
|
665
|
+
while(removable){
|
666
|
+
removable = false;
|
667
|
+
for(i = 0; i < groupCount; i++){
|
668
|
+
let groupId = groupIds[i];
|
669
|
+
let group = groupMap[groupId];
|
670
|
+
if(!group){
|
671
|
+
continue;
|
672
|
+
}
|
673
|
+
|
674
|
+
let children = group["children"];
|
675
|
+
let childCount = children.length;
|
676
|
+
let validChildren = [];
|
677
|
+
for(j = 0; j < childCount; j++){
|
678
|
+
let child = children[j];
|
679
|
+
if(validIds[child]){
|
680
|
+
validChildren.push(child);
|
681
|
+
}
|
682
|
+
}
|
683
|
+
|
684
|
+
if(validChildren.length < 2) {
|
685
|
+
delete groupMap[groupId];
|
686
|
+
validIds[groupId] = 0;
|
687
|
+
removable = true;
|
688
|
+
} else {
|
689
|
+
group.children = validChildren;
|
690
|
+
}
|
691
|
+
}
|
692
|
+
}
|
661
693
|
};
|
662
694
|
|
663
695
|
/** Set a timer to call applyGrouping only once to avoid performance issue
|
664
696
|
* @private
|
665
697
|
*/
|
666
|
-
ColumnGroupingPlugin.prototype._requestApplyGrouping = function
|
667
|
-
|
668
|
-
|
669
|
-
|
698
|
+
ColumnGroupingPlugin.prototype._requestApplyGrouping = function() {
|
699
|
+
if(!this._rerenderTimerId) {
|
700
|
+
this._rerenderTimerId = setTimeout(this._applyGrouping.bind(this), 10);
|
701
|
+
}
|
670
702
|
};
|
671
703
|
/** Set a timer to call renderGroups only once to avoid performance issue
|
672
704
|
* @private
|
673
705
|
*/
|
674
|
-
ColumnGroupingPlugin.prototype._requestGroupRendering = function
|
675
|
-
|
676
|
-
|
677
|
-
|
706
|
+
ColumnGroupingPlugin.prototype._requestGroupRendering = function() {
|
707
|
+
if(!this._groupHeaderTimerId) {
|
708
|
+
this._groupHeaderTimerId = setTimeout(this.renderGroups.bind(this), 10);
|
709
|
+
}
|
678
710
|
};
|
679
711
|
/** Apply nearest grouping to column.
|
680
712
|
* @private
|
681
713
|
* @param {number} colIndex
|
682
714
|
*/
|
683
715
|
ColumnGroupingPlugin.prototype._applyNearestGrouping = function (colIndex) {
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
716
|
+
if(colIndex == null || colIndex < 0 ){
|
717
|
+
return;
|
718
|
+
}
|
719
|
+
|
720
|
+
let colId = this.getColumnId(colIndex);
|
721
|
+
let colIndexLeft = colIndex - 1;
|
722
|
+
let colIndexRight = colIndex + 1;
|
723
|
+
|
724
|
+
let groupLeftIds = this.getGroupIds(colIndexLeft);
|
725
|
+
let groupRightIds = this.getGroupIds(colIndexRight);
|
726
|
+
let groupLeftCount = groupLeftIds ? groupLeftIds.length : 0;
|
727
|
+
let groupRightCount = groupRightIds ? groupRightIds.length : 0;
|
728
|
+
|
729
|
+
let parentId = this._groupDefs.getParentId(colId);
|
730
|
+
if(parentId) {
|
731
|
+
let chdr = this._groupDefs.getGroupChildren(parentId);
|
732
|
+
let childCount = chdr ? chdr.length : 0;
|
733
|
+
if(childCount <= 1) { // If current column is only child in the group
|
734
|
+
return; // there is no need to put column into another group because its parent group will be moved along
|
735
|
+
}
|
736
|
+
|
737
|
+
// If current column has a group and stays close to its siblings, it stay in the same group
|
738
|
+
if(groupLeftCount) {
|
739
|
+
if(groupLeftIds[0] === parentId) {
|
740
|
+
return;
|
741
|
+
}
|
742
|
+
}
|
743
|
+
if(groupRightCount) {
|
744
|
+
if(groupRightIds[0] === parentId) {
|
745
|
+
return;
|
746
|
+
}
|
747
|
+
}
|
748
|
+
// The current column is no longer close to its parent
|
749
|
+
if(this._groupDefs.unsetParent(colId)) {
|
750
|
+
chdr = this._groupDefs.getGroupChildren(parentId);
|
751
|
+
childCount = chdr ? chdr.length : 0;
|
752
|
+
if(childCount === 1) { // If there is only one child left, move the remaning child to its parent
|
753
|
+
let grandParentId = this._groupDefs.getParentId(parentId);
|
754
|
+
if(grandParentId) {
|
755
|
+
this._groupDefs.addGroupChild(grandParentId, chdr[0]);
|
756
|
+
}
|
757
|
+
}
|
758
|
+
}
|
759
|
+
}
|
760
|
+
|
761
|
+
if(groupLeftCount && groupRightCount) {
|
762
|
+
for(let i = 0; i < groupLeftCount; i++) {
|
763
|
+
let groupLeftId = groupLeftIds[i];
|
764
|
+
let sharedParentIdx = groupRightIds.indexOf(groupLeftId);
|
765
|
+
if(sharedParentIdx >= 0) {
|
766
|
+
this._groupDefs.addGroupChild(groupRightIds[sharedParentIdx], colId);
|
767
|
+
break;
|
768
|
+
}
|
769
|
+
}
|
770
|
+
}
|
737
771
|
};
|
738
772
|
/** @private
|
739
773
|
* @param {Object=} titleSection
|
740
774
|
*/
|
741
775
|
ColumnGroupingPlugin.prototype._spanGroupVertically = function (titleSection) {
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
776
|
+
let api = this.getGridApi();
|
777
|
+
if(!api) {
|
778
|
+
return;
|
779
|
+
}
|
780
|
+
let core = this._hosts[0];
|
781
|
+
|
782
|
+
let maxDepth = this._maxDepth;
|
783
|
+
let rowCount = maxDepth + 1;
|
784
|
+
let colCount = api.getColumnCount();
|
785
|
+
|
786
|
+
for(let col = 0; col < colCount; col++) {
|
787
|
+
let toSpan = rowCount;
|
788
|
+
let parentNode = this._getVisibleParentGroup(this.getColumnId(col));
|
789
|
+
|
790
|
+
if(parentNode) {
|
791
|
+
let depth = parentNode["onRow"] + 1;
|
792
|
+
toSpan = rowCount - depth;
|
793
|
+
}
|
794
|
+
|
795
|
+
// Note that invisible column cannot have row span
|
796
|
+
if(core.isColumnVisible(col) && toSpan > 1) {
|
797
|
+
titleSection.setCellRowSpan(col, rowCount - toSpan, toSpan);
|
798
|
+
}
|
799
|
+
}
|
763
800
|
};
|
764
801
|
/** @private
|
765
802
|
* @param {Object} titleSection
|
766
803
|
*/
|
767
804
|
ColumnGroupingPlugin.prototype._spanGroupHorizontally = function (titleSection) {
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
805
|
+
let section = titleSection;
|
806
|
+
let visibleGroupMap = this._visibleGroupMap;
|
807
|
+
|
808
|
+
// Span column of column group
|
809
|
+
let groupDef, spanIndices, len, colIds, index, i;
|
810
|
+
for(let id in visibleGroupMap) {
|
811
|
+
spanIndices = [];
|
812
|
+
groupDef = visibleGroupMap[id];
|
813
|
+
colIds = GroupDefinitions.getLeafDescendants(visibleGroupMap, id);
|
814
|
+
let isAllSelected = this._selectedColMap ? true : false;
|
815
|
+
for(i = 0; i < colIds.length; i++) {
|
816
|
+
let colId = colIds[i];
|
817
|
+
index = this._getColumnIndexById(colId);
|
818
|
+
if(index > -1) {
|
819
|
+
spanIndices.push(index);
|
820
|
+
}
|
821
|
+
if(isAllSelected && this._selectedColMap){
|
822
|
+
isAllSelected &= this._selectedColMap[colId];
|
823
|
+
}
|
824
|
+
}
|
825
|
+
spanIndices.sort(ColumnGroupingPlugin._ascSortLogic);
|
826
|
+
len = spanIndices.length;
|
827
|
+
if(len > 0) { // This could be unnecessary
|
828
|
+
let start = spanIndices[0];
|
829
|
+
let end = spanIndices[len - 1];
|
830
|
+
section.setCellColSpan(start, groupDef["onRow"], end - start + 1);
|
831
|
+
groupDef["colIndex"] = start;
|
832
|
+
|
833
|
+
if(isAllSelected){
|
834
|
+
let cell = section.getCell(start, groupDef["onRow"]);
|
835
|
+
cell.addClass("selected-group");
|
836
|
+
}
|
837
|
+
}
|
838
|
+
}
|
802
839
|
};
|
803
840
|
/** Render all column group headers without affecting cell spans.
|
804
841
|
* @public
|
805
842
|
*/
|
806
843
|
ColumnGroupingPlugin.prototype.renderGroups = function () {
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
844
|
+
this._groupHeaderTimerId = 0;
|
845
|
+
let hostCount = this._hosts.length;
|
846
|
+
let groupMap = this._visibleGroupMap;
|
847
|
+
for(let i = 0; i < hostCount; ++i) {
|
848
|
+
let section = this._hosts[i].getSection("title");
|
849
|
+
if(!section) {
|
850
|
+
continue;
|
851
|
+
}
|
852
|
+
|
853
|
+
for(let id in groupMap) {
|
854
|
+
this._renderGroup(groupMap[id], section);
|
855
|
+
}
|
856
|
+
}
|
819
857
|
};
|
820
858
|
|
821
859
|
/** @public
|
822
860
|
* @param {Array<string|number>} colRefs
|
823
861
|
* @return {string} groupId if all the given columns are children of that groupId, otherwise empty string
|
824
862
|
*/
|
825
|
-
ColumnGroupingPlugin.prototype.getMutualGroupId = function
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
return "";
|
863
|
+
ColumnGroupingPlugin.prototype.getMutualGroupId = function(colRefs) {
|
864
|
+
let colCount = colRefs.length;
|
865
|
+
for(let i = 0; i < colCount; i++) {
|
866
|
+
if(typeof colRefs[i] === "string") {
|
867
|
+
colRefs[i] = this.getColumnIndex(colRefs[i]);
|
868
|
+
}
|
869
|
+
let colIndex = colRefs[i];
|
870
|
+
let groupIds = this.getGroupIds(colIndex);
|
871
|
+
if(!groupIds) { // If at least 1 column is not part of a group, there is no need to find the groupId.
|
872
|
+
return "";
|
873
|
+
}
|
874
|
+
let groupCount = groupIds.length;
|
875
|
+
for(let j = 0; j < groupCount; j++) {
|
876
|
+
let groupId = groupIds[j];
|
877
|
+
let childrenIndices = this.getChildColumnIndices(groupId);
|
878
|
+
if(deepEqual(childrenIndices, colRefs)) {
|
879
|
+
return groupId;
|
880
|
+
}
|
881
|
+
}
|
882
|
+
}
|
883
|
+
return "";
|
847
884
|
};
|
848
885
|
/** Render single column group header without affecting cell span.
|
849
886
|
* @private
|
850
887
|
* @param {Object} groupDef
|
851
888
|
* @param {Object} section
|
852
889
|
*/
|
853
|
-
ColumnGroupingPlugin.prototype._renderGroup = function
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
890
|
+
ColumnGroupingPlugin.prototype._renderGroup = function(groupDef, section) {
|
891
|
+
let colIndex = groupDef["colIndex"];
|
892
|
+
if(colIndex == null) {
|
893
|
+
return;
|
894
|
+
}
|
895
|
+
let rowIndex = groupDef["onRow"];
|
896
|
+
let cell = section.getCell(colIndex, rowIndex);
|
897
|
+
let colIds = GroupDefinitions.getLeafDescendants(this._visibleGroupMap, groupDef["id"]);
|
898
|
+
let isAllSelected = false;
|
899
|
+
if(this._selectedColMap){
|
900
|
+
isAllSelected = true;
|
901
|
+
for(let i = 0; i < colIds.length; i++) {
|
902
|
+
if(!this._selectedColMap[colIds[i]]){
|
903
|
+
isAllSelected = false;
|
904
|
+
break;
|
905
|
+
}
|
906
|
+
}
|
907
|
+
}
|
908
|
+
|
909
|
+
if(cell) {
|
910
|
+
// Overide the defaults
|
911
|
+
cell.setStyle("text-align", groupDef["alignment"] || "");
|
912
|
+
cell.setTooltip(ColumnGroupingPlugin._getTooltip(groupDef));
|
913
|
+
cell.setContent(groupDef["name"] || groupDef["title"]);
|
914
|
+
|
915
|
+
// Additional cell settings must be removed in the _applyGrouping() method
|
916
|
+
cell.addClass("no-sort");
|
917
|
+
cell.setAttribute("group-id", groupDef["id"]);
|
918
|
+
|
919
|
+
if(isAllSelected){
|
920
|
+
cell.addClass("selected-group");
|
921
|
+
} else {
|
922
|
+
cell.removeClass("selected-group");
|
923
|
+
}
|
924
|
+
|
925
|
+
if(groupDef["legacyRender"]) {
|
926
|
+
// Built-in version if render receive colIndex, cell, groupDefinition as arguments
|
927
|
+
groupDef["legacyRender"](colIndex, cell, groupDef);
|
928
|
+
}
|
929
|
+
|
930
|
+
if(groupDef["render"]) {
|
931
|
+
let arg = {};
|
932
|
+
arg["cell"] = cell;
|
933
|
+
arg["colIndex"] = colIndex;
|
934
|
+
arg["groupNode"] = groupDef;
|
935
|
+
groupDef["render"](arg);
|
936
|
+
}
|
937
|
+
}
|
897
938
|
};
|
898
939
|
|
899
940
|
/** @private
|
900
941
|
* @param {Object} e
|
901
942
|
*/
|
902
943
|
ColumnGroupingPlugin.prototype._onPostSectionRender = function (e) {
|
903
|
-
|
904
|
-
|
905
|
-
|
944
|
+
if(e.sectionType === "title" && !this._restructuring) {
|
945
|
+
this.renderGroups();
|
946
|
+
}
|
906
947
|
};
|
907
948
|
|
908
949
|
/** @private
|
909
950
|
* @param {Object} e dispatching of columnAdded event object
|
910
951
|
*/
|
911
952
|
ColumnGroupingPlugin.prototype._requestApplyAddChildGroup = function (e) {
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
953
|
+
let ctx = e.context;
|
954
|
+
let tsParentDef = ctx ? ctx.parent : null;
|
955
|
+
|
956
|
+
if(tsParentDef) {
|
957
|
+
this._addingEvents.push(e);
|
958
|
+
if(!this._addingTimerId) {
|
959
|
+
this._addingTimerId = setTimeout(this._applyTimeSeries.bind(this, e), 10);
|
960
|
+
}
|
961
|
+
}
|
920
962
|
};
|
921
963
|
|
964
|
+
|
922
965
|
/** @private
|
923
966
|
* @param {Object} e dispatching of columnAdded event object
|
924
967
|
*/
|
925
968
|
ColumnGroupingPlugin.prototype._applyTimeSeries = function (e) {
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
}
|
973
|
-
|
974
|
-
this._requestApplyGrouping();
|
969
|
+
this._addingTimerId = 0; // clear timer
|
970
|
+
let addingEvents = this._addingEvents;
|
971
|
+
this._addingEvents = [];
|
972
|
+
if(addingEvents.length > 0) {
|
973
|
+
let children = [];
|
974
|
+
let timeSeriesId, timeSeriesName;
|
975
|
+
let tsgChild = {};
|
976
|
+
for(let i = 0; i < addingEvents.length; i++) { // WARNING: addingEvents column can be difference group
|
977
|
+
let addingEvent = addingEvents[i];
|
978
|
+
timeSeriesName = addingEvent.context.timeSeriesName;
|
979
|
+
timeSeriesId = addingEvent.context.timeSeriesId;
|
980
|
+
let childIndex, childId;
|
981
|
+
if(!tsgChild[timeSeriesId]) {
|
982
|
+
tsgChild[timeSeriesId] = {
|
983
|
+
name: timeSeriesName,
|
984
|
+
children: []
|
985
|
+
};
|
986
|
+
childIndex = addingEvent.colIndex;
|
987
|
+
childId = this.getColumnId(childIndex);
|
988
|
+
tsgChild[timeSeriesId].children.push(childId);
|
989
|
+
} else {
|
990
|
+
childIndex = addingEvent.colIndex;
|
991
|
+
childId = this.getColumnId(childIndex);
|
992
|
+
tsgChild[timeSeriesId].children.push(childId);
|
993
|
+
}
|
994
|
+
}
|
995
|
+
for(timeSeriesId in tsgChild) {
|
996
|
+
let groupId = "timeSerieGroup_" + timeSeriesId;
|
997
|
+
let groupDef = this._groupDefs.getGroup(groupId);
|
998
|
+
if(groupDef) {
|
999
|
+
// add children time series field to parent
|
1000
|
+
for(i = 0; i < children.length; i++) {
|
1001
|
+
this._groupDefs.addGroupChild(groupId, children[i]);
|
1002
|
+
}
|
1003
|
+
} else {
|
1004
|
+
// create new group
|
1005
|
+
this.addGroup({
|
1006
|
+
id: groupId,
|
1007
|
+
title: tsgChild[timeSeriesId].name,
|
1008
|
+
children: tsgChild[timeSeriesId].children,
|
1009
|
+
timeSeriesGroup: true // For remove it when getConfigObject
|
1010
|
+
});
|
1011
|
+
}
|
1012
|
+
}
|
1013
|
+
}
|
1014
|
+
this._requestApplyGrouping();
|
975
1015
|
};
|
976
1016
|
|
977
1017
|
/** @private
|
978
1018
|
* @param {Object} e dispatching of columnAdded event object
|
979
1019
|
*/
|
980
1020
|
ColumnGroupingPlugin.prototype._onColumnAdded = function (e) {
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
1021
|
+
let batches = e["batches"];
|
1022
|
+
if(!(batches && batches["reset"])) {
|
1023
|
+
this._requestApplyAddChildGroup(e);
|
1024
|
+
this._applyNearestGrouping(e.colIndex);
|
1025
|
+
}
|
1026
|
+
|
1027
|
+
this._requestApplyGrouping();
|
987
1028
|
};
|
988
1029
|
/** @private
|
989
1030
|
*/
|
990
1031
|
ColumnGroupingPlugin.prototype._onColumnChanged = function () {
|
991
|
-
|
1032
|
+
this._requestApplyGrouping();
|
992
1033
|
};
|
993
1034
|
/** @private
|
994
1035
|
* @param {Object} e dispatching of columnMoved event object
|
995
1036
|
*/
|
996
1037
|
ColumnGroupingPlugin.prototype._onColumnMoved = function (e) {
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1038
|
+
let batches = e["batches"];
|
1039
|
+
if(!(batches && batches["move"])) {
|
1040
|
+
this._applyNearestGrouping(e.toColIndex);
|
1041
|
+
}
|
1042
|
+
this._requestApplyGrouping();
|
1002
1043
|
};
|
1003
1044
|
/** @private
|
1004
1045
|
* @param {Object} e
|
1005
1046
|
*/
|
1006
|
-
ColumnGroupingPlugin.prototype._onColumnRemoved = function
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1047
|
+
ColumnGroupingPlugin.prototype._onColumnRemoved = function(e) {
|
1048
|
+
let batches = e["batches"];
|
1049
|
+
if(!(batches && batches["reset"])) {
|
1050
|
+
let colId = e.colId;
|
1051
|
+
if(colId) {
|
1052
|
+
if(this._groupDefs.unsetParent(colId)) {
|
1053
|
+
this._requestApplyGrouping();
|
1054
|
+
}
|
1055
|
+
}
|
1056
|
+
} else {
|
1057
|
+
this._requestApplyGrouping();
|
1058
|
+
}
|
1018
1059
|
};
|
1019
1060
|
/** @private
|
1020
1061
|
* @param {Object} e
|
1021
1062
|
*/
|
1022
|
-
ColumnGroupingPlugin.prototype._onBeforeColumnBoundUpdate = function
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1063
|
+
ColumnGroupingPlugin.prototype._onBeforeColumnBoundUpdate = function(e) {
|
1064
|
+
let selectedColumns = e.selectedColumns; // Hidden columns are included
|
1065
|
+
|
1066
|
+
// Find non-grouped column
|
1067
|
+
let i, colId, nonGroupedColId, groupId;
|
1068
|
+
let colIds = [];
|
1069
|
+
let groupMap = {};
|
1070
|
+
for(i = 0; i < selectedColumns.length; i++) {
|
1071
|
+
colId = this.getColumnId(selectedColumns[i]);
|
1072
|
+
if(colId) {
|
1073
|
+
groupId = this._groupDefs.getParentId(colId);
|
1074
|
+
if(!groupId) {
|
1075
|
+
nonGroupedColId = colId;
|
1076
|
+
break;
|
1077
|
+
} else {
|
1078
|
+
groupMap[groupId] = this._groupDefs.getGroup(groupId); // Cache group node for further calculation
|
1079
|
+
}
|
1080
|
+
colIds.push(colId); // Cache column id for further calculation
|
1081
|
+
}
|
1082
|
+
}
|
1083
|
+
if(nonGroupedColId) {
|
1084
|
+
e.topBoundRowIndex = 0;
|
1085
|
+
return;
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
let topBoundRowIndex = this._maxDepth; // Column title row
|
1089
|
+
|
1090
|
+
// Find minimum row index of group
|
1091
|
+
let rootGroupMap = {};
|
1092
|
+
let headerRowIndex, group;
|
1093
|
+
for(groupId in groupMap) {
|
1094
|
+
group = this._groupDefs.getRootGroup(groupId);
|
1095
|
+
rootGroupMap[group.id] = group;
|
1096
|
+
headerRowIndex = groupMap[groupId].onRow + 1;
|
1097
|
+
if(headerRowIndex < topBoundRowIndex) {
|
1098
|
+
topBoundRowIndex = headerRowIndex;
|
1099
|
+
}
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
// Traverse down from the root group to find group that its all members are selected
|
1103
|
+
let n, members, allSelected, findingGroup, children;
|
1104
|
+
let nextLevelGroups = rootGroupMap;
|
1105
|
+
for(i = 0; i < topBoundRowIndex; i++) {
|
1106
|
+
findingGroup = nextLevelGroups;
|
1107
|
+
nextLevelGroups = {};
|
1108
|
+
for(groupId in findingGroup) {
|
1109
|
+
group = findingGroup[groupId];
|
1110
|
+
allSelected = true;
|
1111
|
+
members = this._groupDefs.getLeafDescendants(groupId);
|
1112
|
+
if(members.length <= colIds.length) {
|
1113
|
+
for(n = 0; n < members.length; n++) {
|
1114
|
+
if(colIds.indexOf(members[n]) < 0) {
|
1115
|
+
allSelected = false;
|
1116
|
+
break;
|
1117
|
+
}
|
1118
|
+
}
|
1119
|
+
if(allSelected) {
|
1120
|
+
e.topBoundRowIndex = i;
|
1121
|
+
return;
|
1122
|
+
}
|
1123
|
+
}
|
1124
|
+
|
1125
|
+
// Cache the next level group
|
1126
|
+
children = group.children;
|
1127
|
+
for(n = 0; n < children.length; n++) {
|
1128
|
+
let id = children[n];
|
1129
|
+
group = this._groupDefs.getGroup(id);
|
1130
|
+
if(group) {
|
1131
|
+
nextLevelGroups[id] = group;
|
1132
|
+
}
|
1133
|
+
}
|
1134
|
+
}
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
// Find maximum spanned row count
|
1138
|
+
let section = this._hosts[0].getSection("title");
|
1139
|
+
let minRowSpanCount = 0;
|
1140
|
+
let bottomRowIndex = this._maxDepth;
|
1141
|
+
for (i = 0; i < selectedColumns.length; i++) {
|
1142
|
+
let rowSpanCount = section.getCellRowSpan(selectedColumns[i], bottomRowIndex);
|
1143
|
+
if(rowSpanCount < minRowSpanCount) {
|
1144
|
+
minRowSpanCount = rowSpanCount;
|
1145
|
+
}
|
1146
|
+
}
|
1147
|
+
|
1148
|
+
e.topBoundRowIndex = bottomRowIndex + minRowSpanCount;
|
1149
|
+
};
|
1150
|
+
/** @private
|
1151
|
+
* @param {String} groupId
|
1152
|
+
* @return {boolean}
|
1153
|
+
*/
|
1154
|
+
ColumnGroupingPlugin.prototype._isChildSelected = function(groupId) {
|
1155
|
+
let childIndices = this.getChildColumnIndices(groupId);
|
1156
|
+
if(childIndices && childIndices.length) {
|
1157
|
+
let host = this._hosts[0];
|
1158
|
+
for(let i = 0; i < childIndices.length; i++) {
|
1159
|
+
if(host.isSelectedColumn(childIndices[i])) {
|
1160
|
+
return true;
|
1161
|
+
}
|
1162
|
+
}
|
1163
|
+
}
|
1164
|
+
return false;
|
1165
|
+
};
|
1166
|
+
/** @private
|
1167
|
+
*/
|
1168
|
+
ColumnGroupingPlugin.prototype._updateColumnBounds = function() {
|
1169
|
+
let hosts = this._hosts;
|
1170
|
+
for(let i = 0; i < hosts.length; i++) {
|
1171
|
+
let host = hosts[i];
|
1172
|
+
if(host.updateColumnBounds) { // Keep backward compatibility
|
1173
|
+
host.updateColumnBounds();
|
1174
|
+
}
|
1175
|
+
}
|
1108
1176
|
};
|
1109
1177
|
/** Deprecated. Column should be directly added through grid APIs.
|
1110
1178
|
* @deprecated
|
@@ -1114,24 +1182,26 @@ ColumnGroupingPlugin.prototype._onBeforeColumnBoundUpdate = function (e) {
|
|
1114
1182
|
* @param {number} colIndex Column index
|
1115
1183
|
*/
|
1116
1184
|
ColumnGroupingPlugin.prototype.addColumnToGroup = function (column, groupId, colIndex) {
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1185
|
+
if(!column) return;
|
1186
|
+
|
1187
|
+
let destIndex = this.getColumnCount();
|
1188
|
+
if(colIndex != null) {
|
1189
|
+
let groupDef = this._groupDefs.getGroup(groupId);
|
1190
|
+
if(groupDef) {
|
1191
|
+
this._groupDefs.addGroupChild(groupId, column.id);
|
1192
|
+
}
|
1193
|
+
destIndex = colIndex;
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
if(this._realTimeGrid) { // TODO: Support multi-table feature
|
1197
|
+
this._realTimeGrid.insertColumn(column, destIndex);
|
1198
|
+
} else if(this._compositeGrid) {
|
1199
|
+
this._compositeGrid.insertColumn(destIndex, column);
|
1200
|
+
}
|
1201
|
+
|
1202
|
+
if(colIndex == null) {
|
1203
|
+
this.setColumnParent(column.id || destColIndex, groupId);
|
1204
|
+
}
|
1135
1205
|
};
|
1136
1206
|
|
1137
1207
|
/** Add new group definition to existing group structure. Existing group with the same id will be replaced.
|
@@ -1140,10 +1210,10 @@ ColumnGroupingPlugin.prototype.addColumnToGroup = function (column, groupId, col
|
|
1140
1210
|
* @return {string} Return group ID
|
1141
1211
|
*/
|
1142
1212
|
ColumnGroupingPlugin.prototype.addGroup = function (groupDef) {
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1213
|
+
if(ColumnGroupingPlugin._hasGroupId(groupDef)) {
|
1214
|
+
return this.setGroupDefinition(groupDef.id, groupDef);
|
1215
|
+
}
|
1216
|
+
return "";
|
1147
1217
|
};
|
1148
1218
|
/** Deprecated. Use addGroup() method instead
|
1149
1219
|
* @deprecated
|
@@ -1158,11 +1228,15 @@ ColumnGroupingPlugin.prototype.addColumnGrouping = ColumnGroupingPlugin.prototyp
|
|
1158
1228
|
* @return {boolean}
|
1159
1229
|
*/
|
1160
1230
|
ColumnGroupingPlugin.prototype.removeGroup = function (groupId) {
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1231
|
+
let isChildSelected = this._isChildSelected(groupId);
|
1232
|
+
if(this._groupDefs.removeGroup(groupId)) {
|
1233
|
+
this._applyGrouping();
|
1234
|
+
if(isChildSelected) {
|
1235
|
+
this._updateColumnBounds();
|
1236
|
+
}
|
1237
|
+
return true;
|
1238
|
+
}
|
1239
|
+
return false;
|
1166
1240
|
};
|
1167
1241
|
|
1168
1242
|
/** @public
|
@@ -1170,30 +1244,31 @@ ColumnGroupingPlugin.prototype.removeGroup = function (groupId) {
|
|
1170
1244
|
* @return {ColumnGroupingPlugin~GroupDefinition}
|
1171
1245
|
*/
|
1172
1246
|
ColumnGroupingPlugin.prototype.getGroupDefinition = function (groupId) {
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1247
|
+
let chdr = this._getAvaliableChildren(groupId);
|
1248
|
+
if(chdr.length > 1) {
|
1249
|
+
let groupDef = this._groupDefs.getGroup(groupId);
|
1250
|
+
groupDef = ColumnGroupingPlugin._cloneObject(groupDef); // TODO: this is slow
|
1251
|
+
groupDef.children = chdr;
|
1252
|
+
return groupDef;
|
1253
|
+
}
|
1254
|
+
return null;
|
1181
1255
|
};
|
1182
1256
|
/** Get a shallow copy of all existing group definitions
|
1183
1257
|
* @public
|
1184
1258
|
* @return {!ColumnGroupingPlugin~GroupDefinitions}
|
1185
1259
|
*/
|
1186
1260
|
ColumnGroupingPlugin.prototype.getGroupDefinitions = function () {
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1261
|
+
let validGroupDefs = [];
|
1262
|
+
let groupMap = this._groupDefs.getGroupMap();
|
1263
|
+
for(let grpId in groupMap) {
|
1264
|
+
let groupDef = this.getGroupDefinition(grpId); // Clone
|
1265
|
+
if(groupDef) {
|
1266
|
+
delete groupDef.parentId;
|
1267
|
+
validGroupDefs.push(groupDef);
|
1268
|
+
}
|
1269
|
+
}
|
1270
|
+
|
1271
|
+
return validGroupDefs;
|
1197
1272
|
};
|
1198
1273
|
/** Replace and update existing group definition. New group is added if the given id has no match. Existing group will be removed of no new definition is given.
|
1199
1274
|
* @public
|
@@ -1202,35 +1277,47 @@ ColumnGroupingPlugin.prototype.getGroupDefinitions = function () {
|
|
1202
1277
|
* @return {string} Return group Id. Return empty string if nothing has been changed.
|
1203
1278
|
*/
|
1204
1279
|
ColumnGroupingPlugin.prototype.setGroupDefinition = function (groupId, groupDef) {
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1280
|
+
if(this._groupDefs.setGroup(groupId, groupDef)) {
|
1281
|
+
let newDef = this._groupDefs.getGroup(groupId);
|
1282
|
+
if(newDef) {
|
1283
|
+
let host = this._hosts[0];
|
1284
|
+
let chdr = host.getValidColumnList(newDef.children).map(ColumnGroupingPlugin.getObjectId); //this return only valid columns without group
|
1285
|
+
let len = chdr.length;
|
1286
|
+
if(len > 1) {
|
1287
|
+
this.reorderColumns(chdr, chdr[0]);
|
1288
|
+
}
|
1289
|
+
}
|
1290
|
+
this._applyGrouping();
|
1291
|
+
if(this._isChildSelected(groupId)) {
|
1292
|
+
this._updateColumnBounds();
|
1293
|
+
}
|
1294
|
+
return groupId;
|
1295
|
+
}
|
1296
|
+
return "";
|
1219
1297
|
};
|
1220
1298
|
/** Remove all existing group definitions and replace with the given definitions.
|
1221
1299
|
* @public
|
1222
1300
|
* @param {ColumnGroupingPlugin~GroupDefinitions} groupDefs Use null or empty array to remove all existing groups
|
1223
1301
|
*/
|
1224
1302
|
ColumnGroupingPlugin.prototype.setGroupDefinitions = function (groupDefs) {
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1303
|
+
if(Array.isArray(groupDefs)) {
|
1304
|
+
groupDefs = groupDefs.filter(ColumnGroupingPlugin._hasGroupId);
|
1305
|
+
groupDefs = groupDefs.map(ColumnGroupingPlugin._cloneObject);
|
1306
|
+
} else {
|
1307
|
+
groupDefs = null;
|
1308
|
+
}
|
1309
|
+
ColumnGroupingPlugin._flattenGroupDefs(groupDefs);
|
1310
|
+
this._groupDefs.setGroups(groupDefs);
|
1311
|
+
this._applyGrouping();
|
1312
|
+
|
1313
|
+
let groupIds = this._groupDefs.getGroupIds();
|
1314
|
+
for(let i = 0; i < groupIds.length; i++) {
|
1315
|
+
if(this._isChildSelected(groupIds[i])) {
|
1316
|
+
this._updateColumnBounds();
|
1317
|
+
break;
|
1318
|
+
}
|
1319
|
+
}
|
1320
|
+
this._updateColumnBounds();
|
1234
1321
|
};
|
1235
1322
|
/** Replace and update existing group definition.
|
1236
1323
|
* @public
|
@@ -1239,53 +1326,58 @@ ColumnGroupingPlugin.prototype.setGroupDefinitions = function (groupDefs) {
|
|
1239
1326
|
* @return {boolean}
|
1240
1327
|
*/
|
1241
1328
|
ColumnGroupingPlugin.prototype.setGroupChildren = function (groupId, newChildList) {
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1329
|
+
if(this._groupDefs.setGroupChildren(groupId, newChildList)) {
|
1330
|
+
this._applyGrouping();
|
1331
|
+
if(this._isChildSelected(groupId)) {
|
1332
|
+
this._updateColumnBounds();
|
1333
|
+
}
|
1334
|
+
return true;
|
1335
|
+
}
|
1336
|
+
return false;
|
1247
1337
|
};
|
1248
1338
|
/** @public
|
1249
1339
|
* @param {string} groupId
|
1250
1340
|
* @param {string} groupName
|
1251
1341
|
*/
|
1252
1342
|
ColumnGroupingPlugin.prototype.setGroupName = function (groupId, groupName) {
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1343
|
+
if(this._groupDefs.setGroupName(groupId, groupName)) {
|
1344
|
+
let groupDef = this._visibleGroupMap[groupId];
|
1345
|
+
if(groupDef) {
|
1346
|
+
groupDef.name = groupName;
|
1347
|
+
|
1348
|
+
let hostCount = this._hosts.length;
|
1349
|
+
for(let i = 0; i < hostCount; ++i) {
|
1350
|
+
let section = this._hosts[i].getSection("title");
|
1351
|
+
if(!section) {
|
1352
|
+
continue;
|
1353
|
+
}
|
1354
|
+
|
1355
|
+
this._renderGroup(groupDef, section);
|
1356
|
+
}
|
1357
|
+
}
|
1358
|
+
}
|
1267
1359
|
};
|
1268
1360
|
/** @private
|
1269
1361
|
* @param {string} groupId
|
1270
1362
|
* @return {!Array.<string>} The list of immediate valid child, including invisible child groups
|
1271
1363
|
*/
|
1272
1364
|
ColumnGroupingPlugin.prototype._getAvaliableChildren = function (groupId) {
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1365
|
+
let chdr = this._groupDefs.getGroupChildren(groupId);
|
1366
|
+
let childCount = chdr ? chdr.length : 0;
|
1367
|
+
let validChildren = [];
|
1368
|
+
if(childCount) {
|
1369
|
+
let host = this._hosts[0];
|
1370
|
+
let validCols = host.getValidColumnList(chdr);
|
1371
|
+
validChildren = validCols.map(ColumnGroupingPlugin.getObjectId);
|
1372
|
+
let groupMap = this._groupDefs.getGroupMap();
|
1373
|
+
for(let i = 0; i < childCount; i++) {
|
1374
|
+
let childId = chdr[i];
|
1375
|
+
if(groupMap[childId]) {
|
1376
|
+
validChildren.push(childId);
|
1377
|
+
}
|
1378
|
+
}
|
1379
|
+
}
|
1380
|
+
return validChildren;
|
1289
1381
|
};
|
1290
1382
|
|
1291
1383
|
/** @public
|
@@ -1293,11 +1385,11 @@ ColumnGroupingPlugin.prototype._getAvaliableChildren = function (groupId) {
|
|
1293
1385
|
* @return {Array.<string>}
|
1294
1386
|
*/
|
1295
1387
|
ColumnGroupingPlugin.prototype.getGroupChildren = function (groupId) {
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1388
|
+
let children = this._getAvaliableChildren(groupId);
|
1389
|
+
if(children.length > 1) {
|
1390
|
+
return children;
|
1391
|
+
}
|
1392
|
+
return null;
|
1301
1393
|
};
|
1302
1394
|
|
1303
1395
|
/** Return all column indices under the given group id
|
@@ -1305,36 +1397,36 @@ ColumnGroupingPlugin.prototype.getGroupChildren = function (groupId) {
|
|
1305
1397
|
* @param {string} groupId
|
1306
1398
|
* @return {Array.<number>}
|
1307
1399
|
*/
|
1308
|
-
ColumnGroupingPlugin.prototype.getChildColumnIndices = function
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1400
|
+
ColumnGroupingPlugin.prototype.getChildColumnIndices = function(groupId) {
|
1401
|
+
let colIndices = [];
|
1402
|
+
let host = this._hosts[0];
|
1403
|
+
let colIds = this._groupDefs.getLeafDescendants(groupId);
|
1404
|
+
if(colIds) {
|
1405
|
+
let validColList = host.getValidColumnList(colIds);
|
1406
|
+
colIndices = validColList.map(ColumnGroupingPlugin.getObjectIndex);
|
1407
|
+
return colIndices;
|
1408
|
+
}
|
1409
|
+
return null;
|
1318
1410
|
};
|
1319
1411
|
|
1320
1412
|
/** @public
|
1321
1413
|
* @param {string|number} colRef
|
1322
1414
|
* @return {Array.<string>}
|
1323
1415
|
*/
|
1324
|
-
ColumnGroupingPlugin.prototype.getGroupIds = function
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1416
|
+
ColumnGroupingPlugin.prototype.getGroupIds = function(colRef) {
|
1417
|
+
if(colRef == null) {
|
1418
|
+
return null;
|
1419
|
+
}
|
1420
|
+
let colId = (typeof colRef === "number") ? this.getColumnId(colRef) : colRef;
|
1421
|
+
return this._groupDefs.getParentIds(colId);
|
1330
1422
|
};
|
1331
1423
|
|
1332
1424
|
/** Return deepest row index of column headers
|
1333
1425
|
* @public
|
1334
1426
|
* @return {number}
|
1335
1427
|
*/
|
1336
|
-
ColumnGroupingPlugin.prototype.getMaxGroupLevel = function
|
1337
|
-
|
1428
|
+
ColumnGroupingPlugin.prototype.getMaxGroupLevel = function() {
|
1429
|
+
return this._maxDepth;
|
1338
1430
|
};
|
1339
1431
|
|
1340
1432
|
/** Return row index of the given group id
|
@@ -1342,12 +1434,12 @@ ColumnGroupingPlugin.prototype.getMaxGroupLevel = function () {
|
|
1342
1434
|
* @param {string} groupId
|
1343
1435
|
* @return {number}
|
1344
1436
|
*/
|
1345
|
-
ColumnGroupingPlugin.prototype.getGroupLevel = function
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1437
|
+
ColumnGroupingPlugin.prototype.getGroupLevel = function(groupId) {
|
1438
|
+
let group = this._visibleGroupMap[groupId];
|
1439
|
+
if(group) {
|
1440
|
+
return group.onRow;
|
1441
|
+
}
|
1442
|
+
return -1;
|
1351
1443
|
};
|
1352
1444
|
|
1353
1445
|
/** This version exclude invisible column unlike the one in GridPlugin
|
@@ -1356,135 +1448,150 @@ ColumnGroupingPlugin.prototype.getGroupLevel = function (groupId) {
|
|
1356
1448
|
* @return {number} index of the column
|
1357
1449
|
*/
|
1358
1450
|
ColumnGroupingPlugin.prototype._getColumnIndexById = function (id) {
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1451
|
+
let api = this.getGridApi();
|
1452
|
+
if(api && id) {
|
1453
|
+
let core = this._hosts[0];
|
1454
|
+
let colCount = core.getColumnCount();
|
1455
|
+
for(let c = 0; c < colCount; c++) {
|
1456
|
+
if(this.getColumnId(c) === id && core.isColumnVisible(c)) {
|
1457
|
+
return c;
|
1458
|
+
}
|
1459
|
+
}
|
1460
|
+
}
|
1461
|
+
return -1;
|
1370
1462
|
};
|
1371
1463
|
/** @private
|
1372
1464
|
* @param {string} childId
|
1373
1465
|
* @return {ColumnGroupingPlugin~GroupDefinition}
|
1374
1466
|
*/
|
1375
1467
|
ColumnGroupingPlugin.prototype._getVisibleParentGroup = function (childId) {
|
1376
|
-
|
1468
|
+
return this._visibleGroupMap[this._groupDefs.getParentId(childId)] || null;
|
1377
1469
|
};
|
1378
1470
|
/** @public
|
1379
1471
|
* @param {Element|Event|MouseEvent} e
|
1380
1472
|
* @return {Object}
|
1381
1473
|
*/
|
1382
|
-
ColumnGroupingPlugin.prototype.getCellInfo = function
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1474
|
+
ColumnGroupingPlugin.prototype.getCellInfo = function(e) {
|
1475
|
+
let api = this.getGridApi();
|
1476
|
+
let grid = e["grid"] || this.getRelativeGrid(e);
|
1477
|
+
if(!api || !grid) {
|
1478
|
+
return null;
|
1479
|
+
}
|
1480
|
+
|
1481
|
+
let cellInfo = grid.getCellInfo(e);
|
1482
|
+
if(!cellInfo){
|
1483
|
+
return e;
|
1484
|
+
}
|
1485
|
+
|
1486
|
+
if(!cellInfo["cell"]){
|
1487
|
+
let cell = cellInfo.section.getCell(cellInfo.colIndex, cellInfo.rowIndex);
|
1488
|
+
cellInfo["cell"] = cell;
|
1489
|
+
}
|
1490
|
+
|
1491
|
+
let colId = this.getColumnId(cellInfo.colIndex);
|
1492
|
+
let groupId = this._groupDefs.getParentId(colId, cellInfo.sectionType == "title" ? cellInfo.rowIndex : null);
|
1493
|
+
if(!groupId){
|
1494
|
+
cellInfo["columnId"] = colId;
|
1495
|
+
return cellInfo;
|
1496
|
+
}
|
1497
|
+
|
1498
|
+
let groupInfo = this._groupDefs.getGroup(groupId); // TODO: Check if we need visible group
|
1499
|
+
if(groupInfo) {
|
1500
|
+
let isGroupHeader = cellInfo.sectionType == "title" && cellInfo.rowIndex == this.getGroupLevel(groupId);
|
1501
|
+
if(isGroupHeader){
|
1502
|
+
cellInfo["groupId"] = groupInfo.id;
|
1503
|
+
cellInfo["groupName"] = groupInfo.name || "";
|
1504
|
+
cellInfo["children"] = groupInfo.children;
|
1505
|
+
} else {
|
1506
|
+
cellInfo["columnId"] = colId;
|
1507
|
+
}
|
1508
|
+
cellInfo["parent"] = isGroupHeader ? groupInfo.parentId || null : groupInfo.id;
|
1509
|
+
}
|
1510
|
+
|
1511
|
+
return cellInfo;
|
1415
1512
|
};
|
1416
1513
|
/** @public
|
1417
1514
|
* @param {number|string} colRef Column index or id that should be moved
|
1418
1515
|
* @param {number} to
|
1419
1516
|
* @param {string} groupId
|
1420
1517
|
*/
|
1421
|
-
ColumnGroupingPlugin.prototype.moveColumnIntoGroup = function
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1518
|
+
ColumnGroupingPlugin.prototype.moveColumnIntoGroup = function(colRef, to, groupId) {
|
1519
|
+
let fromIndex = this.getColumnIndex(colRef);
|
1520
|
+
if(fromIndex == -1){
|
1521
|
+
return;
|
1522
|
+
}
|
1523
|
+
|
1524
|
+
let groupDef = this._groupDefs.getGroup(groupId);
|
1525
|
+
if(!groupDef){
|
1526
|
+
for(let j = this._hosts.length; --j >= 0;) {
|
1527
|
+
let grid = this._hosts[j];
|
1528
|
+
grid.moveColumn(fromIndex, to);
|
1529
|
+
}
|
1530
|
+
return;
|
1531
|
+
}
|
1532
|
+
|
1533
|
+
let childIndices = this.getChildColumnIndices(groupId);
|
1534
|
+
let startIndex = -1;
|
1535
|
+
let endIndex = -1;
|
1536
|
+
|
1537
|
+
if(childIndices && childIndices.length){
|
1538
|
+
startIndex = childIndices[0];
|
1539
|
+
endIndex = childIndices[childIndices.length - 1];
|
1540
|
+
} else {
|
1541
|
+
startIndex = 0;
|
1542
|
+
endIndex = this.getColumnCount();
|
1543
|
+
}
|
1544
|
+
|
1545
|
+
if(to < startIndex){
|
1546
|
+
to = startIndex;
|
1547
|
+
// handle move column to right
|
1548
|
+
if(to > fromIndex){
|
1549
|
+
to -= 1;
|
1550
|
+
}
|
1551
|
+
} else
|
1552
|
+
if(to > endIndex) {
|
1553
|
+
to = endIndex;
|
1554
|
+
// handle move column to left
|
1555
|
+
if(to < fromIndex){
|
1556
|
+
to += 1;
|
1557
|
+
}
|
1558
|
+
}
|
1559
|
+
|
1560
|
+
// Calculate left and right bound of the group, which column can be moved to.
|
1561
|
+
// destination should be between the bound, and it should not be placed between columns in child group
|
1562
|
+
for(let i = 0; i < groupDef.children.length; i++){
|
1563
|
+
let notAllowIndices = this.getChildColumnIndices(groupDef.children[i]);
|
1564
|
+
if(notAllowIndices && notAllowIndices.length){
|
1565
|
+
let leftLimit = notAllowIndices[0];
|
1566
|
+
let rightLimit = notAllowIndices[notAllowIndices.length - 1];
|
1567
|
+
|
1568
|
+
if(to > fromIndex){
|
1569
|
+
leftLimit -= 1;
|
1570
|
+
}
|
1571
|
+
|
1572
|
+
if(to < fromIndex){
|
1573
|
+
rightLimit += 1;
|
1574
|
+
}
|
1575
|
+
|
1576
|
+
if(to > leftLimit && to < rightLimit){
|
1577
|
+
to = rightLimit;
|
1578
|
+
}
|
1579
|
+
}
|
1580
|
+
}
|
1581
|
+
|
1582
|
+
// Get column id before start moving
|
1583
|
+
let colId = this.getColumnId(fromIndex);
|
1584
|
+
|
1585
|
+
for(let gridIndex = this._hosts.length; --gridIndex >= 0;) {
|
1586
|
+
let host = this._hosts[gridIndex];
|
1587
|
+
host.moveColumn(fromIndex, to);
|
1588
|
+
}
|
1589
|
+
|
1590
|
+
if(colId) {
|
1591
|
+
if(this._groupDefs.addGroupChild(groupId, colId)) {
|
1592
|
+
this._applyGrouping();
|
1593
|
+
}
|
1594
|
+
}
|
1488
1595
|
};
|
1489
1596
|
/**
|
1490
1597
|
* @public
|
@@ -1492,11 +1599,11 @@ ColumnGroupingPlugin.prototype.moveColumnIntoGroup = function (colRef, to, group
|
|
1492
1599
|
* @param {string} groupId
|
1493
1600
|
* @return {boolean}
|
1494
1601
|
*/
|
1495
|
-
ColumnGroupingPlugin.prototype.setColumnParent = function
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1602
|
+
ColumnGroupingPlugin.prototype.setColumnParent = function(colRef, groupId) {
|
1603
|
+
if(groupId) {
|
1604
|
+
return this.addGroupChild(groupId, colRef);
|
1605
|
+
}
|
1606
|
+
return this.unsetParent(colRef);
|
1500
1607
|
};
|
1501
1608
|
/** If a column is added as a new child in a group, the column will be moved to the last position in the group. If the column is already a child of the group, nothing happens.
|
1502
1609
|
* @public
|
@@ -1504,97 +1611,116 @@ ColumnGroupingPlugin.prototype.setColumnParent = function (colRef, groupId) {
|
|
1504
1611
|
* @param {number|string} childRef Column index, column id, group id to be added
|
1505
1612
|
* @return {boolean}
|
1506
1613
|
*/
|
1507
|
-
ColumnGroupingPlugin.prototype.addGroupChild = function
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1614
|
+
ColumnGroupingPlugin.prototype.addGroupChild = function(parentId, childRef) {
|
1615
|
+
let parentDef = this._groupDefs.getGroup(parentId);
|
1616
|
+
if(!parentDef) {
|
1617
|
+
return false;
|
1618
|
+
}
|
1619
|
+
let colId = "";
|
1620
|
+
if(typeof childRef === "string") {
|
1621
|
+
let groupDef = this._groupDefs.getGroup(childRef);
|
1622
|
+
if(groupDef) {
|
1623
|
+
if(this._groupDefs.addGroupChild(parentId, childRef)) {
|
1624
|
+
this._applyGrouping();
|
1625
|
+
if(this._isChildSelected(parentId)) {
|
1626
|
+
this._updateColumnBounds();
|
1627
|
+
}
|
1628
|
+
return true;
|
1629
|
+
}
|
1630
|
+
} else {
|
1631
|
+
colId = childRef;
|
1632
|
+
}
|
1633
|
+
} else {
|
1634
|
+
colId = this.getColumnId(childRef);
|
1635
|
+
}
|
1636
|
+
if(!colId) {
|
1637
|
+
return false;
|
1638
|
+
}
|
1639
|
+
|
1640
|
+
let leafIndices = this.getChildColumnIndices(parentId);
|
1641
|
+
if(this._groupDefs.addGroupChild(parentId, colId)) {
|
1642
|
+
if(leafIndices && leafIndices.length) {
|
1643
|
+
if(this.moveColumnById(colId, leafIndices[leafIndices.length - 1] + 1)) {
|
1644
|
+
return true;
|
1645
|
+
}
|
1646
|
+
}
|
1647
|
+
|
1648
|
+
this._applyGrouping();
|
1649
|
+
if(this._isChildSelected(parentId)) {
|
1650
|
+
this._updateColumnBounds();
|
1651
|
+
}
|
1652
|
+
return true;
|
1653
|
+
}
|
1654
|
+
|
1655
|
+
return false;
|
1540
1656
|
};
|
1541
1657
|
/**
|
1542
1658
|
* @public
|
1543
1659
|
* @param {string} parentId
|
1544
|
-
* @param {number|string} childRef Column index, column id, group id to be
|
1660
|
+
* @param {number|string} childRef Column index, column id, group id to be removed
|
1545
1661
|
* @return {boolean}
|
1546
1662
|
*/
|
1547
|
-
ColumnGroupingPlugin.prototype.removeGroupChild = function
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1663
|
+
ColumnGroupingPlugin.prototype.removeGroupChild = function(parentId, childRef) {
|
1664
|
+
let parentDef = this._groupDefs.getGroup(parentId);
|
1665
|
+
if(!parentDef) {
|
1666
|
+
return false;
|
1667
|
+
}
|
1668
|
+
let colId = "";
|
1669
|
+
if(typeof childRef === "string") {
|
1670
|
+
let groupDef = this._groupDefs.getGroup(childRef);
|
1671
|
+
if(groupDef) {
|
1672
|
+
if(this._groupDefs.unsetParent(childRef)) {
|
1673
|
+
this._applyGrouping();
|
1674
|
+
if(this._isChildSelected(parentId)) {
|
1675
|
+
this._updateColumnBounds();
|
1676
|
+
}
|
1677
|
+
return true;
|
1678
|
+
}
|
1679
|
+
} else {
|
1680
|
+
colId = childRef;
|
1681
|
+
}
|
1682
|
+
} else {
|
1683
|
+
colId = this.getColumnId(childRef);
|
1684
|
+
}
|
1685
|
+
if(!colId) {
|
1686
|
+
return false;
|
1687
|
+
}
|
1688
|
+
|
1689
|
+
let rootId = parentId;
|
1690
|
+
let group = this._visibleGroupMap[parentId];
|
1691
|
+
if(group.onRow !== 0) {
|
1692
|
+
rootId = this._groupDefs.getParentId(parentId, 0);
|
1693
|
+
}
|
1694
|
+
|
1695
|
+
let leafIndices = this.getChildColumnIndices(rootId);
|
1696
|
+
if(this._groupDefs.removeGroupChild(parentId, colId)) {
|
1697
|
+
if(leafIndices && leafIndices.length > 1) {
|
1698
|
+
if(this.moveColumnById(colId, leafIndices[leafIndices.length - 1] + 1)) {
|
1699
|
+
return true;
|
1700
|
+
}
|
1701
|
+
}
|
1702
|
+
|
1703
|
+
this._applyGrouping();
|
1704
|
+
if(this._isChildSelected(parentId)) {
|
1705
|
+
this._updateColumnBounds();
|
1706
|
+
}
|
1707
|
+
return true;
|
1708
|
+
}
|
1709
|
+
|
1710
|
+
return false;
|
1585
1711
|
};
|
1586
1712
|
/**
|
1587
1713
|
* @public
|
1588
1714
|
* @param {number|string} childRef Column index, column id, group id to be removed from its own parent
|
1589
1715
|
* @return {boolean}
|
1590
1716
|
*/
|
1591
|
-
ColumnGroupingPlugin.prototype.unsetParent = function
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1717
|
+
ColumnGroupingPlugin.prototype.unsetParent = function(childRef) {
|
1718
|
+
let refId = (typeof childRef === "string") ? childRef : this.getColumnId(childRef);
|
1719
|
+
let parentId = this._groupDefs.getParentId(refId);
|
1720
|
+
if(parentId) {
|
1721
|
+
return this.removeGroupChild(parentId, refId);
|
1722
|
+
}
|
1723
|
+
return false;
|
1598
1724
|
};
|
1599
1725
|
|
1600
1726
|
/** @public
|
@@ -1603,63 +1729,70 @@ ColumnGroupingPlugin.prototype.unsetParent = function (childRef) {
|
|
1603
1729
|
* @param {number|string} destCol destination column index / id
|
1604
1730
|
* @returns {number} destination index
|
1605
1731
|
*/
|
1606
|
-
ColumnGroupingPlugin.prototype.getValidDestinationIndex = function
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1732
|
+
ColumnGroupingPlugin.prototype.getValidDestinationIndex = function(id, destCol) {
|
1733
|
+
let parentGroupDef = null;
|
1734
|
+
if(this._groupDefs.getGroup(id)){
|
1735
|
+
parentGroupDef = this._getVisibleParentGroup(id);
|
1736
|
+
} else if(this.getColumnIndex(id) > -1) {
|
1737
|
+
parentGroupDef = this._getVisibleParentGroup(id);
|
1738
|
+
}
|
1739
|
+
|
1740
|
+
let startIndex = -1;
|
1741
|
+
let endIndex = -1;
|
1742
|
+
let destColIndex = typeof destCol === "string" ? this.getColumnIndex(destCol) : destCol;
|
1743
|
+
|
1744
|
+
if(parentGroupDef){
|
1745
|
+
|
1746
|
+
// If group/column is a child of a group, it should be move within the parent group
|
1747
|
+
let childIndices = this.getChildColumnIndices(parentGroupDef["id"]);
|
1748
|
+
if(childIndices && childIndices.length){
|
1749
|
+
startIndex = childIndices[0];
|
1750
|
+
endIndex = childIndices[childIndices.length - 1];
|
1751
|
+
}
|
1752
|
+
if(destColIndex < startIndex && destColIndex != -1){
|
1753
|
+
destColIndex = this.getColumnId(startIndex);
|
1754
|
+
} else
|
1755
|
+
if(destColIndex > endIndex || destColIndex == -1) {
|
1756
|
+
destColIndex = this.getColumnId(endIndex + 1);
|
1757
|
+
}
|
1758
|
+
|
1759
|
+
// handle group/column should not insert between group
|
1760
|
+
let groupChildren = this.getGroupChildren(parentGroupDef["id"]);
|
1761
|
+
for(let i = 0; i < groupChildren.length; i++){
|
1762
|
+
let childId = groupChildren[i];
|
1763
|
+
let childGroupIndices = this.getChildColumnIndices(childId);
|
1764
|
+
if(childGroupIndices && childGroupIndices.length){
|
1765
|
+
startIndex = childGroupIndices[0];
|
1766
|
+
endIndex = childGroupIndices[childGroupIndices.length - 1];
|
1767
|
+
if(destColIndex > startIndex && destColIndex <= endIndex){
|
1768
|
+
destColIndex = endIndex + 1;
|
1769
|
+
break;
|
1770
|
+
}
|
1771
|
+
}
|
1772
|
+
}
|
1773
|
+
|
1774
|
+
} else {
|
1775
|
+
// handle group/column should not insert between group when group/column is not a child of any group
|
1776
|
+
let destMemberIndices = [];
|
1777
|
+
let destColId = this.getColumnId(destColIndex);
|
1778
|
+
let destParent = this._getVisibleParentGroup(destColId);
|
1779
|
+
if(destParent){
|
1780
|
+
if(destParent.parentId){
|
1781
|
+
destParent = this._groupDefs.getRootGroup(destParent["id"]);
|
1782
|
+
}
|
1783
|
+
destMemberIndices = this.getChildColumnIndices(destParent["id"]);
|
1784
|
+
}
|
1785
|
+
|
1786
|
+
if(destMemberIndices && destMemberIndices.length){
|
1787
|
+
startIndex = destMemberIndices[0];
|
1788
|
+
endIndex = destMemberIndices[destMemberIndices.length - 1];
|
1789
|
+
if(destColIndex > startIndex && destColIndex <= endIndex){
|
1790
|
+
destColIndex = endIndex + 1;
|
1791
|
+
}
|
1792
|
+
}
|
1793
|
+
}
|
1794
|
+
|
1795
|
+
return destColIndex;
|
1663
1796
|
};
|
1664
1797
|
|
1665
1798
|
/** @public
|
@@ -1669,26 +1802,28 @@ ColumnGroupingPlugin.prototype.getValidDestinationIndex = function (id, destCol)
|
|
1669
1802
|
* @param {string} id group id or column id
|
1670
1803
|
* @param {(number|string)=} destCol destination column index / id
|
1671
1804
|
*/
|
1672
|
-
ColumnGroupingPlugin.prototype.moveGroup = function
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1805
|
+
ColumnGroupingPlugin.prototype.moveGroup = function(id, destCol) {
|
1806
|
+
let groupDef;
|
1807
|
+
let members = [];
|
1808
|
+
|
1809
|
+
groupDef = this._groupDefs.getGroup(id);
|
1810
|
+
if(groupDef){
|
1811
|
+
let indices = this.getChildColumnIndices(groupDef["id"]);
|
1812
|
+
for(let i = 0; i < indices.length; i++){
|
1813
|
+
let index = indices[i];
|
1814
|
+
let colId = this.getColumnId(index);
|
1815
|
+
members.push(colId);
|
1816
|
+
}
|
1817
|
+
} else if(this.getColumnIndex(id) > -1) {
|
1818
|
+
members.push(id);
|
1819
|
+
} else {
|
1820
|
+
return;
|
1821
|
+
}
|
1822
|
+
|
1823
|
+
let destColIndex = this.getValidDestinationIndex(id, destCol);
|
1824
|
+
let destColId = this.getColumnId(destColIndex); // TODO: This may not necessary
|
1825
|
+
|
1826
|
+
this.reorderColumns(members, destColId);
|
1692
1827
|
};
|
1693
1828
|
/** Move and reorder the specified columns to position before the destination
|
1694
1829
|
* @public
|
@@ -1696,8 +1831,8 @@ ColumnGroupingPlugin.prototype.moveGroup = function (id, destCol) {
|
|
1696
1831
|
* @param {(number|string)=} destCol Destination column id or index
|
1697
1832
|
* @return {boolean}
|
1698
1833
|
*/
|
1699
|
-
ColumnGroupingPlugin.prototype.reorderColumns = function
|
1700
|
-
|
1834
|
+
ColumnGroupingPlugin.prototype.reorderColumns = function(colList, destCol) {
|
1835
|
+
return this._reorderColumns(colList, destCol);
|
1701
1836
|
};
|
1702
1837
|
/** Move the specified column to position before the destination
|
1703
1838
|
* @public
|
@@ -1705,113 +1840,123 @@ ColumnGroupingPlugin.prototype.reorderColumns = function (colList, destCol) {
|
|
1705
1840
|
* @param {(number|string)=} destCol Destination column id or index
|
1706
1841
|
* @return {boolean}
|
1707
1842
|
*/
|
1708
|
-
ColumnGroupingPlugin.prototype.moveColumnById = function
|
1709
|
-
|
1843
|
+
ColumnGroupingPlugin.prototype.moveColumnById = function(srcCol, destCol) {
|
1844
|
+
return this._moveColumnById(srcCol, destCol);
|
1710
1845
|
};
|
1711
1846
|
/** @public
|
1712
1847
|
* @param {string} groupId
|
1713
1848
|
* @param {string=} side Available values are: left|right. If no value is supplied, all columns will be pinned to the left.
|
1714
1849
|
*/
|
1715
|
-
ColumnGroupingPlugin.prototype.pinGroup = function
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1850
|
+
ColumnGroupingPlugin.prototype.pinGroup = function(groupId, side) {
|
1851
|
+
if(!groupId) {
|
1852
|
+
return;
|
1853
|
+
}
|
1854
|
+
|
1855
|
+
let groupDef = this._visibleGroupMap[groupId];
|
1856
|
+
if(!groupDef) {
|
1857
|
+
return;
|
1858
|
+
}
|
1859
|
+
|
1860
|
+
let host = this._hosts[0];
|
1861
|
+
let leftPinnedIndex = host.getFrozenColumnCount() - 1;
|
1862
|
+
let rightPinnedCount = host.getPinnedRightColumnCount();
|
1863
|
+
let colCount = this.getColumnCount();
|
1864
|
+
let colList = this.getChildColumnIndices(groupId);
|
1865
|
+
let len = colList.length;
|
1866
|
+
|
1867
|
+
let dest;
|
1868
|
+
if(side === "right") {
|
1869
|
+
if(groupDef.rightPinned) {
|
1870
|
+
return;
|
1871
|
+
}
|
1872
|
+
if(groupDef.leftPinned) {
|
1873
|
+
this.unpinGroup(groupId);
|
1874
|
+
leftPinnedIndex = host.getFrozenColumnCount() - 1;
|
1875
|
+
}
|
1876
|
+
groupDef.rightPinned = true;
|
1877
|
+
dest = colCount - rightPinnedCount;
|
1878
|
+
rightPinnedCount = rightPinnedCount + len;
|
1879
|
+
} else {
|
1880
|
+
if(groupDef.leftPinned) {
|
1881
|
+
return;
|
1882
|
+
}
|
1883
|
+
if(groupDef.rightPinned) {
|
1884
|
+
this.unpinGroup(groupId);
|
1885
|
+
rightPinnedCount = host.getPinnedRightColumnCount();
|
1886
|
+
}
|
1887
|
+
groupDef.leftPinned = true;
|
1888
|
+
dest = leftPinnedIndex === -1 ? 0 : leftPinnedIndex + 1;
|
1889
|
+
leftPinnedIndex = leftPinnedIndex + len;
|
1890
|
+
}
|
1891
|
+
|
1892
|
+
this.moveGroup(groupId, dest);
|
1893
|
+
this._freezeColumn(leftPinnedIndex, rightPinnedCount);
|
1755
1894
|
};
|
1756
1895
|
/** @public
|
1757
1896
|
* @param {string} groupId
|
1758
1897
|
* @param {(number|string)=} dest The unpinned group will be placed before the destination position after the operation
|
1759
1898
|
*/
|
1760
|
-
ColumnGroupingPlugin.prototype.unpinGroup = function
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1899
|
+
ColumnGroupingPlugin.prototype.unpinGroup = function(groupId, dest) {
|
1900
|
+
if(!groupId) {
|
1901
|
+
return;
|
1902
|
+
}
|
1903
|
+
|
1904
|
+
let groupDef = this._visibleGroupMap[groupId];
|
1905
|
+
if(!groupDef) {
|
1906
|
+
return;
|
1907
|
+
}
|
1908
|
+
|
1909
|
+
if(!groupDef.leftPinned && !groupDef.rightPinned) {
|
1910
|
+
return;
|
1911
|
+
}
|
1912
|
+
|
1913
|
+
let host = this._hosts[0];
|
1914
|
+
let leftPinnedCount = host.getFrozenColumnCount();
|
1915
|
+
let rightPinnedCount = host.getPinnedRightColumnCount();
|
1916
|
+
let colCount = this.getColumnCount();
|
1917
|
+
let firstRightPinnedIndex = colCount - rightPinnedCount;
|
1918
|
+
let colList = this.getChildColumnIndices(groupId);
|
1919
|
+
let len = colList.length;
|
1920
|
+
|
1921
|
+
let destId = null;
|
1922
|
+
if(dest != null) {
|
1923
|
+
let destIdx = this.getColumnIndex(dest);
|
1924
|
+
destId = this.getColumnId(destIdx);
|
1925
|
+
}
|
1926
|
+
|
1927
|
+
if(groupDef.leftPinned) {
|
1928
|
+
groupDef.leftPinned = false;
|
1929
|
+
this.moveGroup(groupId, leftPinnedCount);
|
1930
|
+
this._freezeColumn(leftPinnedCount - (1 + len));
|
1931
|
+
} else if(groupDef.rightPinned) {
|
1932
|
+
groupDef.rightPinned = false;
|
1933
|
+
this.moveGroup(groupId, firstRightPinnedIndex);
|
1934
|
+
this._freezeColumn(leftPinnedCount - 1, rightPinnedCount - len);
|
1935
|
+
}
|
1936
|
+
|
1937
|
+
if(destId != null) {
|
1938
|
+
this.moveGroup(groupId, destId);
|
1939
|
+
}
|
1795
1940
|
};
|
1796
1941
|
/** @public
|
1797
1942
|
* @param {Array<number>} colIndices
|
1798
1943
|
*/
|
1799
|
-
ColumnGroupingPlugin.prototype.selectGroupHeaders = function
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1944
|
+
ColumnGroupingPlugin.prototype.selectGroupHeaders = function(colIndices) {
|
1945
|
+
let host = this._hosts[0];
|
1946
|
+
let count = colIndices.length;
|
1947
|
+
if(host && count){
|
1948
|
+
let colIds = [];
|
1949
|
+
for(let i = 0; i < count; i++){
|
1950
|
+
colIds.push(host.getColumnId(colIndices[i]));
|
1951
|
+
}
|
1952
|
+
let colMap = host.createColumnMap(colIds);
|
1953
|
+
if(colMap){
|
1954
|
+
this._selectedColMap = colMap;
|
1955
|
+
}
|
1956
|
+
} else {
|
1957
|
+
this._selectedColMap = null;
|
1958
|
+
}
|
1959
|
+
this._requestGroupRendering();
|
1815
1960
|
};
|
1816
1961
|
|
1817
1962
|
/** Get column index from column object
|
@@ -1820,8 +1965,8 @@ ColumnGroupingPlugin.prototype.selectGroupHeaders = function (colIndices) {
|
|
1820
1965
|
* @param {Object} column
|
1821
1966
|
* @return {number}
|
1822
1967
|
*/
|
1823
|
-
ColumnGroupingPlugin.getObjectIndex = function
|
1824
|
-
|
1968
|
+
ColumnGroupingPlugin.getObjectIndex = function(column) {
|
1969
|
+
return column["index"];
|
1825
1970
|
};
|
1826
1971
|
|
1827
1972
|
/** Get column id from column object
|
@@ -1830,8 +1975,11 @@ ColumnGroupingPlugin.getObjectIndex = function (column) {
|
|
1830
1975
|
* @param {Object} column
|
1831
1976
|
* @return {string}
|
1832
1977
|
*/
|
1833
|
-
ColumnGroupingPlugin.getObjectId = function
|
1834
|
-
|
1978
|
+
ColumnGroupingPlugin.getObjectId = function(column) {
|
1979
|
+
return column["id"];
|
1835
1980
|
};
|
1981
|
+
|
1982
|
+
|
1983
|
+
|
1836
1984
|
export default ColumnGroupingPlugin;
|
1837
|
-
export { ColumnGroupingPlugin, ColumnGroupingPlugin as ColumnGrouping, ColumnGroupingPlugin as ColumnGroupingExtension };
|
1985
|
+
export { ColumnGroupingPlugin, ColumnGroupingPlugin as ColumnGrouping, ColumnGroupingPlugin as ColumnGroupingExtension };
|