@refinitiv-ui/efx-grid 6.0.26 → 6.0.28
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/core/dist/core.js +287 -34
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/DataTable.d.ts +1 -1
- package/lib/core/es6/data/DataTable.js +3 -2
- package/lib/core/es6/data/DataView.d.ts +1 -1
- package/lib/core/es6/data/DataView.js +3 -2
- package/lib/core/es6/data/Segment.d.ts +1 -1
- package/lib/core/es6/data/Segment.js +12 -3
- package/lib/core/es6/data/SegmentCollection.d.ts +1 -1
- package/lib/core/es6/data/SegmentCollection.js +3 -2
- package/lib/core/es6/grid/Core.d.ts +17 -3
- package/lib/core/es6/grid/Core.js +226 -20
- package/lib/core/es6/grid/components/Scrollbar.js +6 -0
- package/lib/grid/index.js +1 -1
- package/lib/row-segmenting/es6/RowSegmenting.js +21 -2
- package/lib/rt-grid/dist/rt-grid.js +418 -238
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/ColumnDefinition.d.ts +2 -2
- package/lib/rt-grid/es6/ColumnDefinition.js +71 -70
- package/lib/rt-grid/es6/Grid.d.ts +9 -2
- package/lib/rt-grid/es6/Grid.js +55 -132
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +12 -2
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +138 -47
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +14 -1
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +317 -187
- package/lib/tr-grid-range-bar/es6/RangeBar.d.ts +4 -0
- package/lib/tr-grid-range-bar/es6/RangeBar.js +8 -0
- package/lib/tr-grid-util/es6/GridPlugin.d.ts +6 -0
- package/lib/tr-grid-util/es6/GridPlugin.js +67 -0
- package/lib/tr-grid-util/es6/GroupDefinitions.d.ts +5 -1
- package/lib/tr-grid-util/es6/GroupDefinitions.js +34 -5
- package/lib/types/es6/ColumnGrouping.d.ts +12 -2
- package/lib/types/es6/ColumnStack.d.ts +14 -1
- package/lib/types/es6/Core/data/DataTable.d.ts +1 -1
- package/lib/types/es6/Core/data/DataView.d.ts +1 -1
- package/lib/types/es6/Core/data/Segment.d.ts +1 -1
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +1 -1
- package/lib/types/es6/Core/grid/Core.d.ts +17 -3
- package/lib/types/es6/RealtimeGrid/ColumnDefinition.d.ts +2 -2
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +9 -2
- package/lib/versions.json +5 -5
- package/package.json +1 -1
package/lib/rt-grid/es6/Grid.js
CHANGED
@@ -85,6 +85,7 @@ import { ElementWrapper } from "../../core/es6/grid/components/ElementWrapper.js
|
|
85
85
|
* @property {number=} adcPollingInterval=0 Length of polling interval for refreshing ADC data in milliseconds. The default value (0) means no polling.
|
86
86
|
* @property {boolean=} fieldCaching=false If enabled, field definition will be caching internal mechanism
|
87
87
|
* @property {string=} childDataField=CHILD_VALUES The given field will be used to store children's static data, such as row color assignment.
|
88
|
+
* @property {boolean=} topSection=true If disabled, title section will not be rendered
|
88
89
|
*/
|
89
90
|
|
90
91
|
/** @typedef {number|string|RowDefinition} Grid~RowReference
|
@@ -228,26 +229,6 @@ var compareNumber = function(rowDefA, rowDefB, sortOrder, fieldName) { // edit n
|
|
228
229
|
return (rowDefA.getData(fieldName) - rowDefB.getData(fieldName)) * sortOrder; // for numeric comparison
|
229
230
|
};
|
230
231
|
|
231
|
-
/** @private
|
232
|
-
* @param {ColumnDefinition} colDef
|
233
|
-
* @return {string}
|
234
|
-
*/
|
235
|
-
var _getId = function(colDef) {
|
236
|
-
if(colDef) {
|
237
|
-
return colDef.getId();
|
238
|
-
}
|
239
|
-
return "";
|
240
|
-
};
|
241
|
-
/** @private
|
242
|
-
* @param {ColumnDefinition} colDef
|
243
|
-
* @return {string}
|
244
|
-
*/
|
245
|
-
var _getField = function(colDef) {
|
246
|
-
if(colDef) {
|
247
|
-
return colDef.getField();
|
248
|
-
}
|
249
|
-
return "";
|
250
|
-
};
|
251
232
|
/** @private
|
252
233
|
* @param {ColumnDefinition} colDef
|
253
234
|
* @return {string}
|
@@ -336,6 +317,9 @@ var Grid = function(placeholder, config) {
|
|
336
317
|
if(config["SortableTitle"]) { // Exception for built-in plugin
|
337
318
|
t._stp = config["SortableTitle"];
|
338
319
|
}
|
320
|
+
if(config["topSection"] === false) {
|
321
|
+
t._topSection = false;
|
322
|
+
}
|
339
323
|
}
|
340
324
|
if(!t._sharedDataSource) {
|
341
325
|
t._dc = new DataCache();
|
@@ -550,7 +534,10 @@ Grid.prototype._fieldCaching = false;
|
|
550
534
|
* @private
|
551
535
|
*/
|
552
536
|
Grid.prototype._childDataField = "";
|
553
|
-
|
537
|
+
/** @type {boolean}
|
538
|
+
* @private
|
539
|
+
*/
|
540
|
+
Grid.prototype._topSection = true;
|
554
541
|
|
555
542
|
/** @public
|
556
543
|
*/
|
@@ -665,7 +652,11 @@ Grid.prototype.updateRowData = Grid.prototype._updateRowData;
|
|
665
652
|
*/
|
666
653
|
Grid.prototype._addGridSections = function () {
|
667
654
|
var title = this._grid.addSection("title");
|
668
|
-
|
655
|
+
if(this._topSection == false){
|
656
|
+
title.setRowCount(0);
|
657
|
+
} else {
|
658
|
+
title.setRowCount(1);
|
659
|
+
}
|
669
660
|
this._grid.addSection("content");
|
670
661
|
|
671
662
|
var titleSettings = this._grid.getSectionSettings("title");
|
@@ -1617,10 +1608,13 @@ Grid.prototype.setFields = Grid.prototype.setColumns;
|
|
1617
1608
|
* @param {Object} e
|
1618
1609
|
*/
|
1619
1610
|
Grid.prototype._onColumnAdded = function(e) {
|
1620
|
-
var colDef = e.context[COL_DEF];
|
1611
|
+
var colDef = /** @type{ColumnDefinition} */(e.context[COL_DEF]);
|
1621
1612
|
delete e.context[COL_DEF];
|
1622
1613
|
var idx = e.colIndex;
|
1623
1614
|
|
1615
|
+
var coreColDef = this._grid._getColumnDef(idx);
|
1616
|
+
colDef._setCoreColumnDef(coreColDef); // For column id and field
|
1617
|
+
|
1624
1618
|
var colData = this._grid.getColumnData(idx);
|
1625
1619
|
if(!colData) { // Save column inside grid
|
1626
1620
|
colData = this._grid.setColumnData(idx, {});
|
@@ -1847,102 +1841,16 @@ Grid.prototype.moveColumn = function (fromColIndex, toColIndex) {
|
|
1847
1841
|
* grid.moveColumnById("sourceColumnId", ""); // move to the last position
|
1848
1842
|
*/
|
1849
1843
|
Grid.prototype.moveColumnById = function (srcCol, destCol) {
|
1850
|
-
|
1851
|
-
var srcIndex = this.getColumnIndex(srcCol);
|
1852
|
-
if(srcIndex < 0 || srcIndex >= colCount) {
|
1853
|
-
return false;
|
1854
|
-
}
|
1855
|
-
var destIndex = this.getColumnIndex(destCol);
|
1856
|
-
if(destIndex < 0) {
|
1857
|
-
destIndex = colCount;
|
1858
|
-
}
|
1859
|
-
return this._moveColumnByIndex(srcIndex, destIndex);
|
1860
|
-
};
|
1861
|
-
/** Move column without verification for better performance
|
1862
|
-
* @private
|
1863
|
-
* @param {number} srcIndex Column index
|
1864
|
-
* @param {number} destIndex Column index of the destination
|
1865
|
-
* @return {boolean} Return true if there is any change, and false otherwise
|
1866
|
-
*/
|
1867
|
-
Grid.prototype._moveColumnByIndex = function (srcIndex, destIndex) {
|
1868
|
-
if(srcIndex < destIndex) { // Ensure that the source column is put in front of the destination index
|
1869
|
-
--destIndex;
|
1870
|
-
}
|
1871
|
-
if(srcIndex === destIndex) {
|
1872
|
-
return false;
|
1873
|
-
}
|
1874
|
-
return this.moveColumn(srcIndex, destIndex);
|
1844
|
+
return this._grid.moveColumnById(srcCol, destCol);
|
1875
1845
|
};
|
1876
1846
|
|
1877
1847
|
/** @public
|
1878
1848
|
* @param {number|string|Array.<number|string>} colRefs List of column index or column id to be moved
|
1879
|
-
* @param {number|string} destCol Destination position where the moved columns will be placed BEFORE the specified position. This can be column id or index
|
1849
|
+
* @param {(number|string)=} destCol Destination position where the moved columns will be placed BEFORE the specified position. This can be column id or index
|
1880
1850
|
* @return {boolean} Return true if there is any change, and false otherwise
|
1881
1851
|
*/
|
1882
1852
|
Grid.prototype.reorderColumns = function (colRefs, destCol) {
|
1883
|
-
|
1884
|
-
|
1885
|
-
if(Array.isArray(colRefs)) {
|
1886
|
-
var srcLen = colRefs.length;
|
1887
|
-
if(srcLen > 1) {
|
1888
|
-
var colIds = this.getColumnIds();
|
1889
|
-
var colCount = colIds.length;
|
1890
|
-
var srcIds = [];
|
1891
|
-
var invalidDest = false;
|
1892
|
-
var i, srcId, srcIdx;
|
1893
|
-
for(i = 0; i < srcLen; ++i) {
|
1894
|
-
var colRef = colRefs[i];
|
1895
|
-
if(typeof colRef === "number") {
|
1896
|
-
srcIdx = colRef;
|
1897
|
-
srcId = colIds[colRef] || "";
|
1898
|
-
} else {
|
1899
|
-
srcId = colRef;
|
1900
|
-
srcIdx = colIds.indexOf(srcId);
|
1901
|
-
}
|
1902
|
-
if(srcId && srcIdx >= 0) {
|
1903
|
-
srcIds.push(srcId);
|
1904
|
-
if(destId === srcId) {
|
1905
|
-
invalidDest = true; // Destination must not exist in source columns
|
1906
|
-
}
|
1907
|
-
}
|
1908
|
-
}
|
1909
|
-
|
1910
|
-
var destIdx;
|
1911
|
-
srcLen = srcIds.length;
|
1912
|
-
if(invalidDest) { // Find the next valid destination where it is not contained in the source columns
|
1913
|
-
destIdx = this.getColumnIndex(destId);
|
1914
|
-
if(destIdx >= 0) {
|
1915
|
-
while(++destIdx < colCount) {
|
1916
|
-
destId = colIds[destIdx];
|
1917
|
-
if(srcIds.indexOf(destId) < 0) {
|
1918
|
-
break;
|
1919
|
-
}
|
1920
|
-
}
|
1921
|
-
}
|
1922
|
-
if(destIdx < 0 || destIdx >= colCount) {
|
1923
|
-
destId = "";
|
1924
|
-
}
|
1925
|
-
}
|
1926
|
-
|
1927
|
-
var dirty = 0;
|
1928
|
-
for(i = srcLen; --i >= 0;) {
|
1929
|
-
srcId = srcIds[i]; // Only valid source columns are left at this point
|
1930
|
-
srcIdx = this.getColumnIndex(srcId);
|
1931
|
-
destIdx = this.getColumnIndex(destId);
|
1932
|
-
if(destIdx < 0) { // Insert to the back when id is not found
|
1933
|
-
destIdx = colCount;
|
1934
|
-
}
|
1935
|
-
dirty |= this._moveColumnByIndex(srcIdx, destIdx);
|
1936
|
-
destId = srcId;
|
1937
|
-
}
|
1938
|
-
return dirty ? true : false;
|
1939
|
-
} else {
|
1940
|
-
return this.moveColumnById(colRefs[0], destId);
|
1941
|
-
}
|
1942
|
-
}
|
1943
|
-
|
1944
|
-
// colRefs will be a number or string
|
1945
|
-
return this.moveColumnById(colRefs, destId);
|
1853
|
+
return this._grid.reorderColumns(colRefs, destCol);
|
1946
1854
|
};
|
1947
1855
|
|
1948
1856
|
/** The hidden column still occupies the same index.
|
@@ -2981,30 +2889,19 @@ Grid.prototype._getRowId = function(rowRef) {
|
|
2981
2889
|
* @return {number}
|
2982
2890
|
*/
|
2983
2891
|
Grid.prototype.getColumnIndex = function(colRef) {
|
2984
|
-
if(typeof colRef === "number") {
|
2985
|
-
return colRef;
|
2986
|
-
}
|
2987
|
-
|
2988
2892
|
if(colRef) {
|
2989
2893
|
var colCount = this.getColumnCount();
|
2990
|
-
var i, colDef;
|
2991
2894
|
if(colRef instanceof ColumnDefinition) {
|
2992
|
-
for(i = 0; i < colCount; ++i) {
|
2993
|
-
colDef = this.getColumnDefinition(i);
|
2895
|
+
for(var i = 0; i < colCount; ++i) {
|
2896
|
+
var colDef = this.getColumnDefinition(i);
|
2994
2897
|
if(colDef === colRef) {
|
2995
2898
|
return i;
|
2996
2899
|
}
|
2997
2900
|
}
|
2998
|
-
|
2999
|
-
for(i = 0; i < colCount; ++i) {
|
3000
|
-
colDef = this.getColumnDefinition(i);
|
3001
|
-
if(_hasFieldOrId(colDef, colRef)) {
|
3002
|
-
return i; // Return the first found field
|
3003
|
-
}
|
3004
|
-
}
|
2901
|
+
return -1;
|
3005
2902
|
}
|
3006
2903
|
}
|
3007
|
-
return
|
2904
|
+
return this._grid.getColumnIndex(colRef);
|
3008
2905
|
};
|
3009
2906
|
/** Any invalid column reference will be excluded from the output array
|
3010
2907
|
* @public
|
@@ -3020,7 +2917,7 @@ Grid.prototype.getColumnIndices = function(colRefs) {
|
|
3020
2917
|
for(var i = 0; i < len; ++i) {
|
3021
2918
|
var colIndex = this.getColumnIndex(inputAry[i]);
|
3022
2919
|
if(colIndex >= 0 && colIndex < colCount) {
|
3023
|
-
ary.push(colIndex); // WARNING: We have not
|
2920
|
+
ary.push(colIndex); // WARNING: We have not checked for duplication
|
3024
2921
|
}
|
3025
2922
|
}
|
3026
2923
|
return ary;
|
@@ -3032,14 +2929,14 @@ Grid.prototype.getColumnIndices = function(colRefs) {
|
|
3032
2929
|
* @see {@link Grid#getColumnDefinition}
|
3033
2930
|
*/
|
3034
2931
|
Grid.prototype.getColumnId = function(colIndex) {
|
3035
|
-
return
|
2932
|
+
return this._grid.getColumnId(colIndex);
|
3036
2933
|
};
|
3037
2934
|
/** Get ids from each column definition.
|
3038
2935
|
* @public
|
3039
2936
|
* @return {!Array.<string>} New array is created
|
3040
2937
|
*/
|
3041
2938
|
Grid.prototype.getColumnIds = function() {
|
3042
|
-
return this.
|
2939
|
+
return this._grid.getColumnIds();
|
3043
2940
|
};
|
3044
2941
|
/** Return field defined in the column definition
|
3045
2942
|
* @public
|
@@ -3048,14 +2945,14 @@ Grid.prototype.getColumnIds = function() {
|
|
3048
2945
|
* @see {@link Grid#getColumnDefinition}
|
3049
2946
|
*/
|
3050
2947
|
Grid.prototype.getColumnField = function(colIndex) {
|
3051
|
-
return
|
2948
|
+
return this._grid.getColumnField(colIndex);
|
3052
2949
|
};
|
3053
2950
|
/** Get fields from each column definition. Note that this does not include any required field or data fields. Duplicates may exist.
|
3054
2951
|
* @public
|
3055
2952
|
* @return {!Array.<string>} New array is created
|
3056
2953
|
*/
|
3057
2954
|
Grid.prototype.getColumnFields = function() {
|
3058
|
-
return this.
|
2955
|
+
return this._grid.getColumnFields();
|
3059
2956
|
};
|
3060
2957
|
/** Get column name from each column definition. Note that this does not include any required field or data fields. Duplicates may exist.
|
3061
2958
|
* @public
|
@@ -3513,6 +3410,32 @@ Grid.prototype.setClassification = function(rowRef, fields) {
|
|
3513
3410
|
return false;
|
3514
3411
|
};
|
3515
3412
|
|
3413
|
+
/** Check element in the grid element
|
3414
|
+
* @public
|
3415
|
+
* @param {Element} elem
|
3416
|
+
* @return {boolean}=true if an element from the parameter is inside a grid element
|
3417
|
+
*/
|
3418
|
+
Grid.prototype.contains = function(elem) {
|
3419
|
+
if(elem) {
|
3420
|
+
// This will impact the contents within the rt-grid element, but not those outside of it, such as the wrapper elements atlas-blotter and ef-grid.
|
3421
|
+
return this._topNode.contains(elem);
|
3422
|
+
}
|
3423
|
+
return false;
|
3424
|
+
};
|
3425
|
+
|
3426
|
+
/** Check grid element is focused
|
3427
|
+
* @public
|
3428
|
+
* @return {boolean}
|
3429
|
+
*/
|
3430
|
+
Grid.prototype.isFocused = function() {
|
3431
|
+
var activeElement = document.activeElement;
|
3432
|
+
if(!activeElement || !activeElement.shadowRoot) {
|
3433
|
+
// active element is not in the shadow DOM. try using contains method to check
|
3434
|
+
return this.contains(activeElement);
|
3435
|
+
}
|
3436
|
+
// For wrapper scenarios, such as atlas-blotter or efx-grid
|
3437
|
+
return activeElement.shadowRoot === this._topNode.parentNode;
|
3438
|
+
};
|
3516
3439
|
/** @description Focus grid element without moving window scrollbar
|
3517
3440
|
* @public
|
3518
3441
|
*/
|
@@ -69,11 +69,21 @@ declare class ColumnGroupingPlugin extends GridPlugin {
|
|
69
69
|
|
70
70
|
public moveColumnIntoGroup(colRef: number|string|null, to: number, groupId: string): void;
|
71
71
|
|
72
|
-
public setColumnParent(colRef: number|string|null, groupId: string):
|
72
|
+
public setColumnParent(colRef: number|string|null, groupId: string): boolean;
|
73
|
+
|
74
|
+
public addGroupChild(parentId: string, childRef: number|string|null): boolean;
|
75
|
+
|
76
|
+
public removeGroupChild(parentId: string, childRef: number|string|null): boolean;
|
77
|
+
|
78
|
+
public unsetParent(childRef: number|string|null): boolean;
|
73
79
|
|
74
80
|
public getValidDestinationIndex(id: string, destCol: number|string|null): number;
|
75
81
|
|
76
|
-
public moveGroup(id: string, destCol
|
82
|
+
public moveGroup(id: string, destCol?: (number|string)|null): void;
|
83
|
+
|
84
|
+
public reorderColumns(colList: (number|string)[]|null, destCol?: (number|string)|null): boolean;
|
85
|
+
|
86
|
+
public moveColumnById(srcCol: number|string|null, destCol?: (number|string)|null): boolean;
|
77
87
|
|
78
88
|
}
|
79
89
|
|
@@ -318,16 +318,7 @@ ColumnGroupingPlugin.prototype.config = function (options) {
|
|
318
318
|
}
|
319
319
|
var columns = options["columns"];
|
320
320
|
if (columns) {
|
321
|
-
|
322
|
-
for (var i = 0; i < len; ++i) {
|
323
|
-
var colData = this._newColumnData(i);
|
324
|
-
colData["columnGrouping"] = {
|
325
|
-
// used for columnRemoved event
|
326
|
-
id: columns[i].id // TODO: This does not work with runtime change
|
327
|
-
};
|
328
|
-
}
|
329
|
-
|
330
|
-
groupDefs = this._migrateLegacyStructure(groupDefs, options["columns"]);
|
321
|
+
groupDefs = this._migrateLegacyStructure(groupDefs, columns);
|
331
322
|
}
|
332
323
|
if (groupDefs) {
|
333
324
|
ColumnGroupingPlugin._flattenGroupDefs(groupDefs);
|
@@ -591,7 +582,7 @@ ColumnGroupingPlugin.prototype._applyNearestGrouping = function (colIndex) {
|
|
591
582
|
}
|
592
583
|
}
|
593
584
|
// The current column is no longer close to its parent
|
594
|
-
if (this._groupDefs.
|
585
|
+
if (this._groupDefs.unsetParent(colId)) {
|
595
586
|
chdr = this._groupDefs.getGroupChildren(parentId);
|
596
587
|
childCount = chdr ? chdr.length : 0;
|
597
588
|
if (childCount === 1) {
|
@@ -805,10 +796,9 @@ ColumnGroupingPlugin.prototype._onColumnMoved = function (e) {
|
|
805
796
|
* @param {Object} e
|
806
797
|
*/
|
807
798
|
ColumnGroupingPlugin.prototype._onColumnRemoved = function (e) {
|
808
|
-
var
|
809
|
-
if (
|
810
|
-
|
811
|
-
if (this._groupDefs.removeGroupChild(colId)) {
|
799
|
+
var colId = e.colId;
|
800
|
+
if (colId) {
|
801
|
+
if (this._groupDefs.unsetParent(colId)) {
|
812
802
|
this._requestApplyGrouping();
|
813
803
|
}
|
814
804
|
}
|
@@ -1002,11 +992,7 @@ ColumnGroupingPlugin.prototype.setGroupDefinition = function (groupId, groupDef)
|
|
1002
992
|
var len = chdr.length;
|
1003
993
|
// TODO: Filter out group id
|
1004
994
|
if (len > 1) {
|
1005
|
-
|
1006
|
-
if (gridApi && gridApi.reorderColumns) {
|
1007
|
-
// TODO: Support multi-table feature
|
1008
|
-
gridApi.reorderColumns(chdr, chdr[0]); // WARNING: group id doesn't work
|
1009
|
-
}
|
995
|
+
this.reorderColumns(chdr, chdr[0]); // WARNING: group id doesn't work
|
1010
996
|
}
|
1011
997
|
}
|
1012
998
|
|
@@ -1086,10 +1072,10 @@ ColumnGroupingPlugin.prototype.getChildColumnIndices = function (groupId) {
|
|
1086
1072
|
var colIds = this._groupDefs.getLeafDescendants(groupId);
|
1087
1073
|
if (colIds) {
|
1088
1074
|
var colIndices = [];
|
1089
|
-
var
|
1090
|
-
for (var i = 0; i <
|
1091
|
-
index = this.getColumnIndex(colIds[i]);
|
1092
|
-
if (index
|
1075
|
+
var leafCount = colIds.length;
|
1076
|
+
for (var i = 0; i < leafCount; i++) {
|
1077
|
+
var index = this.getColumnIndex(colIds[i]);
|
1078
|
+
if (index >= 0) {
|
1093
1079
|
colIndices.push(index);
|
1094
1080
|
}
|
1095
1081
|
}
|
@@ -1268,31 +1254,114 @@ ColumnGroupingPlugin.prototype.moveColumnIntoGroup = function (colRef, to, group
|
|
1268
1254
|
}
|
1269
1255
|
}
|
1270
1256
|
};
|
1271
|
-
/**
|
1257
|
+
/**
|
1258
|
+
* @public
|
1272
1259
|
* @param {number|string} colRef Column index or id that should be moved
|
1273
1260
|
* @param {string} groupId
|
1261
|
+
* @return {boolean}
|
1274
1262
|
*/
|
1275
1263
|
ColumnGroupingPlugin.prototype.setColumnParent = function (colRef, groupId) {
|
1276
|
-
|
1277
|
-
|
1278
|
-
return;
|
1264
|
+
if (groupId) {
|
1265
|
+
return this.addGroupChild(groupId, colRef);
|
1279
1266
|
}
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1267
|
+
return this.unsetParent(colRef);
|
1268
|
+
};
|
1269
|
+
/** 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.
|
1270
|
+
* @public
|
1271
|
+
* @param {string} parentId
|
1272
|
+
* @param {number|string} childRef Column index, column id, group id to be added
|
1273
|
+
* @return {boolean}
|
1274
|
+
*/
|
1275
|
+
ColumnGroupingPlugin.prototype.addGroupChild = function (parentId, childRef) {
|
1276
|
+
var parentDef = this._groupDefs.getGroup(parentId);
|
1277
|
+
if (!parentDef) {
|
1278
|
+
return false;
|
1279
|
+
}
|
1280
|
+
var colId = "";
|
1281
|
+
if (typeof childRef === "string") {
|
1282
|
+
var groupDef = this._groupDefs.getGroup(childRef);
|
1283
|
+
if (groupDef) {
|
1284
|
+
if (this._groupDefs.addGroupChild(parentId, childRef)) {
|
1285
|
+
this._applyGrouping();
|
1286
|
+
return true;
|
1287
|
+
}
|
1288
|
+
} else {
|
1289
|
+
colId = childRef;
|
1290
|
+
}
|
1291
|
+
} else {
|
1292
|
+
colId = this.getColumnId(childRef);
|
1293
|
+
}
|
1294
|
+
if (!colId) {
|
1295
|
+
return false;
|
1296
|
+
}
|
1297
|
+
var leafIndices = this.getChildColumnIndices(parentId);
|
1298
|
+
if (this._groupDefs.addGroupChild(parentId, colId)) {
|
1299
|
+
if (leafIndices && leafIndices.length) {
|
1300
|
+
if (this.moveColumnById(colId, leafIndices[leafIndices.length - 1] + 1)) {
|
1301
|
+
return true;
|
1302
|
+
}
|
1303
|
+
}
|
1304
|
+
this._applyGrouping();
|
1305
|
+
return true;
|
1306
|
+
}
|
1307
|
+
return false;
|
1308
|
+
};
|
1309
|
+
/**
|
1310
|
+
* @public
|
1311
|
+
* @param {string} parentId
|
1312
|
+
* @param {number|string} childRef Column index, column id, group id to be added
|
1313
|
+
* @return {boolean}
|
1314
|
+
*/
|
1315
|
+
ColumnGroupingPlugin.prototype.removeGroupChild = function (parentId, childRef) {
|
1316
|
+
var parentDef = this._groupDefs.getGroup(parentId);
|
1317
|
+
if (!parentDef) {
|
1318
|
+
return false;
|
1319
|
+
}
|
1320
|
+
var colId = "";
|
1321
|
+
if (typeof childRef === "string") {
|
1322
|
+
var groupDef = this._groupDefs.getGroup(childRef);
|
1323
|
+
if (groupDef) {
|
1324
|
+
if (this._groupDefs.unsetParent(childRef)) {
|
1325
|
+
this._applyGrouping();
|
1326
|
+
return true;
|
1327
|
+
}
|
1328
|
+
} else {
|
1329
|
+
colId = childRef;
|
1330
|
+
}
|
1288
1331
|
} else {
|
1289
|
-
|
1332
|
+
colId = this.getColumnId(childRef);
|
1290
1333
|
}
|
1291
|
-
|
1334
|
+
if (!colId) {
|
1335
|
+
return false;
|
1336
|
+
}
|
1337
|
+
var leafIndices = this.getChildColumnIndices(parentId);
|
1338
|
+
if (this._groupDefs.removeGroupChild(parentId, colId)) {
|
1339
|
+
if (leafIndices && leafIndices.length > 1) {
|
1340
|
+
if (this.moveColumnById(colId, leafIndices[leafIndices.length - 1] + 1)) {
|
1341
|
+
return true;
|
1342
|
+
}
|
1343
|
+
}
|
1344
|
+
this._applyGrouping();
|
1345
|
+
return true;
|
1346
|
+
}
|
1347
|
+
return false;
|
1348
|
+
};
|
1349
|
+
/**
|
1350
|
+
* @public
|
1351
|
+
* @param {number|string} childRef Column index, column id, group id to be removed from its own parent
|
1352
|
+
* @return {boolean}
|
1353
|
+
*/
|
1354
|
+
ColumnGroupingPlugin.prototype.unsetParent = function (childRef) {
|
1355
|
+
var refId = typeof childRef === "string" ? childRef : this.getColumnId(childRef);
|
1356
|
+
var parentId = this._groupDefs.getParentId(refId);
|
1357
|
+
if (parentId) {
|
1358
|
+
return this.removeGroupChild(parentId, refId);
|
1359
|
+
}
|
1360
|
+
return false;
|
1292
1361
|
};
|
1293
1362
|
|
1294
1363
|
/** @public
|
1295
|
-
* Get a valid index for moving group/column to specific index
|
1364
|
+
* @description Get a valid index for moving group/column to specific index.
|
1296
1365
|
* @param {string} id group id or column id
|
1297
1366
|
* @param {number|string} destCol destination column index / id
|
1298
1367
|
* @returns {number} destination index
|
@@ -1357,11 +1426,11 @@ ColumnGroupingPlugin.prototype.getValidDestinationIndex = function (id, destCol)
|
|
1357
1426
|
};
|
1358
1427
|
|
1359
1428
|
/** @public
|
1360
|
-
* Move group or column to left side of the destination column.
|
1429
|
+
* @description Move group or column to left side of the destination column.
|
1361
1430
|
* Group or column can only be moved within the parent group.
|
1362
1431
|
* If the destination is between other column group, the destination will change to the end of that group instead.
|
1363
1432
|
* @param {string} id group id or column id
|
1364
|
-
* @param {number|string} destCol destination column index / id
|
1433
|
+
* @param {(number|string)=} destCol destination column index / id
|
1365
1434
|
*/
|
1366
1435
|
ColumnGroupingPlugin.prototype.moveGroup = function (id, destCol) {
|
1367
1436
|
var groupDef;
|
@@ -1380,16 +1449,38 @@ ColumnGroupingPlugin.prototype.moveGroup = function (id, destCol) {
|
|
1380
1449
|
return;
|
1381
1450
|
}
|
1382
1451
|
var destColIndex = this.getValidDestinationIndex(id, destCol);
|
1383
|
-
var destColId = this.getColumnId(destColIndex);
|
1452
|
+
var destColId = this.getColumnId(destColIndex); // TODO: This may not necessary
|
1384
1453
|
|
1454
|
+
this.reorderColumns(members, destColId);
|
1455
|
+
};
|
1456
|
+
/** Move and reorder the specified columns to position before the destination
|
1457
|
+
* @public
|
1458
|
+
* @param {Array.<number|string>} colList Column list to be reordered
|
1459
|
+
* @param {(number|string)=} destCol Destination column id or index
|
1460
|
+
* @return {boolean}
|
1461
|
+
*/
|
1462
|
+
ColumnGroupingPlugin.prototype.reorderColumns = function (colList, destCol) {
|
1463
|
+
var dirty = false;
|
1385
1464
|
// TODO: create method for toggling autoGrouping flag
|
1386
|
-
this._autoGrouping = false;
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1465
|
+
this._autoGrouping = false; // Prevent re-grouping in columnMoved event
|
1466
|
+
|
1467
|
+
this._reorderColumns(colList, destCol);
|
1468
|
+
this._autoGrouping = true;
|
1469
|
+
return dirty;
|
1470
|
+
};
|
1471
|
+
/** Move the specified column to position before the destination
|
1472
|
+
* @public
|
1473
|
+
* @param {number|string} srcCol Source column id or index
|
1474
|
+
* @param {(number|string)=} destCol Destination column id or index
|
1475
|
+
* @return {boolean}
|
1476
|
+
*/
|
1477
|
+
ColumnGroupingPlugin.prototype.moveColumnById = function (srcCol, destCol) {
|
1478
|
+
var dirty = false;
|
1479
|
+
this._autoGrouping = false; // Prevent re-grouping in columnMoved event
|
1391
1480
|
|
1481
|
+
this._moveColumnById(srcCol, destCol);
|
1392
1482
|
this._autoGrouping = true;
|
1483
|
+
return dirty;
|
1393
1484
|
};
|
1394
1485
|
export default ColumnGroupingPlugin;
|
1395
1486
|
export { ColumnGroupingPlugin, ColumnGroupingPlugin as ColumnGrouping, ColumnGroupingPlugin as ColumnGroupingExtension };
|
@@ -12,7 +12,8 @@ declare namespace ColumnStackPlugin {
|
|
12
12
|
type Options = {
|
13
13
|
fields: (string)[]|null,
|
14
14
|
stacks: (ColumnStackPlugin.StackDefinition)[]|null,
|
15
|
-
autoStacking?: boolean|null
|
15
|
+
autoStacking?: boolean|null,
|
16
|
+
clicked?: ((...params: any[]) => any)|null
|
16
17
|
};
|
17
18
|
|
18
19
|
type ColumnOptions = {
|
@@ -90,6 +91,8 @@ declare class ColumnStackPlugin extends GridPlugin {
|
|
90
91
|
|
91
92
|
public unstackColumns(colIndices?: (number)[]|null): boolean;
|
92
93
|
|
94
|
+
public removeStack(stackId: string): boolean;
|
95
|
+
|
93
96
|
public removeAllStacks(enableUpdateUI?: boolean|null): boolean;
|
94
97
|
|
95
98
|
public swapColumn(colRef: number|Event|null, swappingIndex: number): boolean;
|
@@ -116,6 +119,16 @@ declare class ColumnStackPlugin extends GridPlugin {
|
|
116
119
|
|
117
120
|
public getActiveColumnField(stackId: string): string;
|
118
121
|
|
122
|
+
public addStackChild(stackId: string, colRef: number|string|null): void;
|
123
|
+
|
124
|
+
public removeStackChild(stackId: string, colRef: number|string|null): void;
|
125
|
+
|
126
|
+
public unsetParent(colRef: number|string|null): void;
|
127
|
+
|
128
|
+
public reorderColumns(colList: (number|string)[]|null, destCol?: (number|string)|null): boolean;
|
129
|
+
|
130
|
+
public moveColumnById(srcCol: number|string|null, destCol?: (number|string)|null): boolean;
|
131
|
+
|
119
132
|
}
|
120
133
|
|
121
134
|
export default ColumnStackPlugin;
|