@refinitiv-ui/efx-grid 6.0.34 → 6.0.36
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/column-dragging/es6/ColumnDragging.js +50 -40
- package/lib/core/dist/core.css +1 -1
- package/lib/core/dist/core.js +248 -8
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/DataCache.js +20 -1
- package/lib/core/es6/data/DataTable.d.ts +2 -0
- package/lib/core/es6/data/DataTable.js +18 -1
- package/lib/core/es6/data/DataView.d.ts +2 -0
- package/lib/core/es6/data/DataView.js +11 -0
- package/lib/core/es6/grid/Core.d.ts +12 -0
- package/lib/core/es6/grid/Core.js +88 -3
- package/lib/core/es6/grid/ILayoutGrid.js +4 -0
- package/lib/core/es6/grid/LayoutGrid.d.ts +4 -0
- package/lib/core/es6/grid/LayoutGrid.js +95 -3
- package/lib/core/es6/grid/VirtualizedLayoutGrid.js +6 -0
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +6 -0
- package/lib/core/es6/tr-grid-theme.js +1 -1
- package/lib/grid/index.js +1 -1
- package/lib/grid/themes/halo/dark/efx-grid.js +1 -1
- package/lib/grid/themes/halo/dark/es5/all-elements.js +1 -1
- package/lib/grid/themes/halo/efx-grid.less +1 -1
- package/lib/grid/themes/halo/light/efx-grid.js +1 -1
- package/lib/grid/themes/halo/light/es5/all-elements.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +367 -148
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.js +37 -31
- package/lib/rt-grid/es6/RowDefSorter.d.ts +5 -5
- package/lib/rt-grid/es6/RowDefSorter.js +165 -71
- package/lib/tr-grid-column-selection/es6/ColumnSelection.js +66 -0
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +3 -0
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +566 -607
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +1 -1
- package/lib/tr-grid-range-bar/es6/RangeBar.d.ts +4 -1
- package/lib/tr-grid-range-bar/es6/RangeBar.js +99 -39
- package/lib/tr-grid-row-dragging/es6/RowDragging.js +14 -3
- package/lib/tr-grid-rowcoloring/es6/RowColoring.js +3 -2
- package/lib/tr-grid-util/es6/DragUI.js +7 -3
- package/lib/tr-grid-util/es6/GroupDefinitions.d.ts +7 -1
- package/lib/tr-grid-util/es6/GroupDefinitions.js +39 -3
- package/lib/tr-grid-util/es6/jet/DataGenerator.js +36 -33
- package/lib/types/es6/ColumnStack.d.ts +2 -0
- package/lib/types/es6/Core/data/DataTable.d.ts +3 -1
- package/lib/types/es6/Core/data/DataView.d.ts +2 -0
- package/lib/types/es6/Core/grid/Core.d.ts +12 -0
- package/lib/types/es6/RealtimeGrid/RowDefSorter.d.ts +5 -5
- package/lib/versions.json +8 -8
- package/package.json +1 -1
package/lib/rt-grid/es6/Grid.js
CHANGED
@@ -326,6 +326,7 @@ var Grid = function(placeholder, config) {
|
|
326
326
|
t._dc = new DataCache();
|
327
327
|
t._dc.listen("dataChanged", t._onDataChanged);
|
328
328
|
t._dc.listen("dataComposed", t._onDataComposed);
|
329
|
+
t._dc.addStaticFields([ROW_DEF, SUB_ID]); // Static fields are deprecated, set fields to be ignore during clone in DataCache
|
329
330
|
|
330
331
|
t._dt = new DataTable();
|
331
332
|
t._dt.setSortingLogic(/** @type{Function} */(t._mainSorter));
|
@@ -1526,8 +1527,11 @@ Grid.prototype.replaceColumn = function (columnOption, colRef) {
|
|
1526
1527
|
if(colDef.getChildren()) { // Parent time series field doesn't provide hidden property
|
1527
1528
|
colConfig["hidden"] = false;
|
1528
1529
|
}
|
1530
|
+
|
1531
|
+
this._grid.startBatch("reset");
|
1529
1532
|
this.insertColumn(colConfig, colIndex);
|
1530
1533
|
this.removeColumn(colIndex + 1); // remove existing column after insert
|
1534
|
+
this._grid.stopBatch("reset");
|
1531
1535
|
};
|
1532
1536
|
|
1533
1537
|
/** to update column name when field info is loaded
|
@@ -1620,21 +1624,24 @@ Grid.prototype._shouldLoadFieldInfo = function (field) {
|
|
1620
1624
|
* @param {Array.<Object>} columns Array of column options
|
1621
1625
|
*/
|
1622
1626
|
Grid.prototype.setColumns = function(columns) {
|
1627
|
+
var grid = this._grid;
|
1623
1628
|
var colCount = (columns) ? columns.length : 0;
|
1624
1629
|
|
1630
|
+
grid.startBatch("reset");
|
1625
1631
|
this.removeAllColumns();
|
1626
1632
|
if(colCount > 0) {
|
1627
1633
|
var prevState = false;
|
1628
1634
|
if(colCount > 1) {
|
1629
|
-
prevState =
|
1635
|
+
prevState = grid.freezeLayout(true); // Insert multiple columns can be a huge time consuming
|
1630
1636
|
}
|
1631
1637
|
for(var i = 0; i < colCount; ++i) {
|
1632
1638
|
this.insertColumn(columns[i], i);
|
1633
1639
|
}
|
1634
1640
|
if(colCount > 1) {
|
1635
|
-
|
1641
|
+
grid.freezeLayout(prevState);
|
1636
1642
|
}
|
1637
1643
|
}
|
1644
|
+
grid.stopBatch("reset");
|
1638
1645
|
};
|
1639
1646
|
|
1640
1647
|
|
@@ -1643,6 +1650,8 @@ Grid.prototype.setColumns = function(columns) {
|
|
1643
1650
|
* @param {Array.<Object>} columns Array of column options
|
1644
1651
|
*/
|
1645
1652
|
Grid.prototype.restoreColumns = function(columns) {
|
1653
|
+
var grid = this._grid;
|
1654
|
+
grid.startBatch("reset");
|
1646
1655
|
var configObj = this.getConfigObject();
|
1647
1656
|
var previousColumns = configObj.columns;
|
1648
1657
|
|
@@ -1706,7 +1715,8 @@ Grid.prototype.restoreColumns = function(columns) {
|
|
1706
1715
|
this._stp.sortColumns(sortingStates);
|
1707
1716
|
}
|
1708
1717
|
|
1709
|
-
|
1718
|
+
grid.reorderColumns(columnOrdering);
|
1719
|
+
grid.stopBatch("reset");
|
1710
1720
|
};
|
1711
1721
|
|
1712
1722
|
/** Remove all existing columns and add new columns based on the given texts/fields
|
@@ -1782,11 +1792,6 @@ Grid.prototype._onColumnAdded = function(e) {
|
|
1782
1792
|
this._grid.enableColumnClass(idx, classes[i]);
|
1783
1793
|
}
|
1784
1794
|
var colField = colDef.getField();
|
1785
|
-
if (!colDef.isRealTimeField()) {
|
1786
|
-
if(this._dc) {
|
1787
|
-
this._dc.addStaticFields([colField]);
|
1788
|
-
}
|
1789
|
-
}
|
1790
1795
|
this._grid.setDataColumnName(idx, ROW_DEF); // This make ColumnDefinition renderer work
|
1791
1796
|
var fields = colDef.getAllFields();
|
1792
1797
|
var referrer = colDef.getId();
|
@@ -3399,33 +3404,34 @@ Grid.prototype._updateStreamingData = function() {
|
|
3399
3404
|
* @param {Object} e
|
3400
3405
|
*/
|
3401
3406
|
Grid.prototype._onPreDataSorting = function (e) {
|
3402
|
-
var
|
3403
|
-
|
3404
|
-
|
3405
|
-
|
3406
|
-
|
3407
|
-
|
3408
|
-
|
3409
|
-
|
3410
|
-
|
3411
|
-
|
3412
|
-
|
3413
|
-
|
3414
|
-
|
3407
|
+
var objs = this._stp.getSortedColumns();
|
3408
|
+
|
3409
|
+
this._sorter.reset();
|
3410
|
+
if(Array.isArray(objs)) {
|
3411
|
+
var sortCount = objs.length;
|
3412
|
+
for(var i = 0; i < sortCount; ++i) {
|
3413
|
+
var obj = objs[i];
|
3414
|
+
var field = obj["field"] || "";
|
3415
|
+
var colIndex = obj["colIndex"];
|
3416
|
+
var colDef = (colIndex >= 0) ? this.getColumnDefinition(colIndex) : null;
|
3417
|
+
|
3418
|
+
var rowSorting = false;
|
3419
|
+
var sortLogic = null;
|
3420
|
+
if(colDef) {
|
3421
|
+
field = colDef.getField(); // WARNING: Field and logic could be out of sync
|
3422
|
+
rowSorting = colDef.isRowSorting();
|
3423
|
+
sortLogic = colDef.getSorter();
|
3424
|
+
}
|
3425
|
+
// TODO: get sortLogic from DataView
|
3426
|
+
// if(!sortLogic && field) {
|
3427
|
+
// sortLogic = state["sortLogic"];
|
3428
|
+
// }
|
3415
3429
|
|
3416
|
-
|
3417
|
-
field = colDef.getField(); // WARNING: Field and logic could be out of sync
|
3418
|
-
sortLogic = colDef.getSorter();
|
3419
|
-
rowSorting = colDef.isRowSorting();
|
3430
|
+
this._sorter.addColumnContext(field, sortLogic, rowSorting, obj["sortOrder"], colIndex, colDef);
|
3420
3431
|
}
|
3421
3432
|
}
|
3422
|
-
if(!sortLogic && field) {
|
3423
|
-
sortLogic = state["sortLogic"];
|
3424
|
-
}
|
3425
3433
|
|
3426
|
-
this._sorter.
|
3427
|
-
this._sorter.setSortLogic(sortLogic);
|
3428
|
-
this._columnSorter = this._sorter.getSorter(rowSorting);
|
3434
|
+
this._columnSorter = this._sorter.getSorter();
|
3429
3435
|
};
|
3430
3436
|
/** @private
|
3431
3437
|
* @param {RowDefinition} rowDefA
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
import { cloneObject } from "../../tr-grid-util/es6/Util.js";
|
2
2
|
|
3
3
|
declare class RowDefSorter {
|
4
4
|
|
@@ -6,14 +6,14 @@ declare class RowDefSorter {
|
|
6
6
|
|
7
7
|
public dispose(): void;
|
8
8
|
|
9
|
-
public getSorter(
|
10
|
-
|
11
|
-
public setSortLogic(func?: ((...params: any[]) => any)|null): void;
|
9
|
+
public getSorter(): ((...params: any[]) => any)|null;
|
12
10
|
|
13
|
-
public
|
11
|
+
public reset(key: string, value: any): void;
|
14
12
|
|
15
13
|
public setContext(key: string, value: any): void;
|
16
14
|
|
15
|
+
public addColumnContext(field: string, logic: ((...params: any[]) => any)|null, rowSorting: boolean, order: string, colIndex: number, colDef: any): void;
|
16
|
+
|
17
17
|
}
|
18
18
|
|
19
19
|
export default RowDefSorter;
|
@@ -1,70 +1,147 @@
|
|
1
|
+
import { cloneObject } from "../../tr-grid-util/es6/Util.js";
|
2
|
+
|
3
|
+
/** @private
|
4
|
+
* @param {*} a
|
5
|
+
* @param {*} b
|
6
|
+
* @param {number} order
|
7
|
+
* @return {number}
|
8
|
+
*/
|
9
|
+
var _defaultCompare = function(a, b, order) {
|
10
|
+
if(a == null || a !== a) {
|
11
|
+
if(b == null || b !== b) {
|
12
|
+
return 0;
|
13
|
+
}
|
14
|
+
return 1;
|
15
|
+
}
|
16
|
+
if(b == null || b !== b) {
|
17
|
+
return -1;
|
18
|
+
}
|
19
|
+
|
20
|
+
if(a < b) {
|
21
|
+
return -order;
|
22
|
+
}
|
23
|
+
if(b < a) {
|
24
|
+
return order;
|
25
|
+
}
|
26
|
+
return 0;
|
27
|
+
};
|
28
|
+
|
1
29
|
/** @constructor
|
2
30
|
*/
|
3
31
|
var RowDefSorter = function() {
|
4
32
|
this._defaultSorter = this._defaultSorter.bind(this);
|
5
33
|
this._dataSorter = this._dataSorter.bind(this);
|
6
34
|
this._rowDefSorter = this._rowDefSorter.bind(this);
|
35
|
+
this._multiColumnsSorter = this._multiColumnsSorter.bind(this);
|
7
36
|
|
8
|
-
this.
|
37
|
+
this._globalContext = {};
|
38
|
+
this._sortParams = [];
|
39
|
+
this._ctxCaches = [];
|
9
40
|
};
|
10
41
|
|
11
|
-
|
12
|
-
/** @type {string}
|
42
|
+
/** @type {!Object}
|
13
43
|
* @private
|
14
44
|
*/
|
15
|
-
RowDefSorter.prototype.
|
16
|
-
/** @type {!
|
45
|
+
RowDefSorter.prototype._globalContext;
|
46
|
+
/** @type {!Array.<Array>}
|
47
|
+
* @private
|
48
|
+
*/
|
49
|
+
RowDefSorter.prototype._sortParams;
|
50
|
+
/** @type {!Array.<Object>}
|
17
51
|
* @private
|
18
52
|
*/
|
19
|
-
RowDefSorter.prototype.
|
20
|
-
/** @type {
|
53
|
+
RowDefSorter.prototype._ctxCaches;
|
54
|
+
/** @type {Array}
|
21
55
|
* @private
|
22
56
|
*/
|
23
|
-
RowDefSorter.prototype.
|
57
|
+
RowDefSorter.prototype._primaryParams;
|
24
58
|
|
25
59
|
|
26
60
|
/** @public
|
27
61
|
*/
|
28
62
|
RowDefSorter.prototype.dispose = function() {
|
29
|
-
this.
|
30
|
-
this.
|
63
|
+
this._globalContext = {}; // Clear any existing reference
|
64
|
+
this._sortParams.length = 0;
|
65
|
+
this._ctxCaches.length = 0;
|
66
|
+
this._primaryParams = null;
|
31
67
|
};
|
32
68
|
|
33
69
|
/** @public
|
34
|
-
* @param {boolean=} rowSorting=false
|
35
70
|
* @return {Function}
|
36
71
|
*/
|
37
|
-
RowDefSorter.prototype.getSorter = function(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
72
|
+
RowDefSorter.prototype.getSorter = function() {
|
73
|
+
this._primaryParams = null;
|
74
|
+
var sortCount = this._sortParams.length;
|
75
|
+
if(sortCount === 1) {
|
76
|
+
var params = this._primaryParams = this._sortParams[0];
|
77
|
+
var sortLogic = params[1];
|
78
|
+
if(sortLogic) {
|
79
|
+
var rowSorting = params[3];
|
80
|
+
return rowSorting ? this._rowDefSorter : this._dataSorter;
|
81
|
+
} else {
|
82
|
+
return this._defaultSorter;
|
83
|
+
}
|
84
|
+
} else if(sortCount > 1) {
|
85
|
+
return this._multiColumnsSorter;
|
42
86
|
}
|
43
|
-
};
|
44
|
-
/** @public
|
45
|
-
* @param {Function=} func
|
46
|
-
*/
|
47
|
-
RowDefSorter.prototype.setSortLogic = function(func) {
|
48
|
-
this._sortLogic = (typeof func === "function") ? func : null;
|
49
|
-
};
|
50
87
|
|
88
|
+
return RowDefSorter._noSorting;
|
89
|
+
};
|
51
90
|
|
52
91
|
/** @public
|
53
|
-
* @param {string}
|
92
|
+
* @param {string} key
|
93
|
+
* @param {*} value
|
54
94
|
*/
|
55
|
-
RowDefSorter.prototype.
|
56
|
-
if(
|
57
|
-
|
95
|
+
RowDefSorter.prototype.reset = function() {
|
96
|
+
if(this._sortParams.length) {
|
97
|
+
this._sortParams.length = 0;
|
58
98
|
}
|
59
|
-
this._sortContext["field"] = this._field = field;
|
60
|
-
this._sortContext["formattedField"] = field + "_FORMATTED";
|
61
99
|
};
|
62
100
|
/** @public
|
63
101
|
* @param {string} key
|
64
102
|
* @param {*} value
|
65
103
|
*/
|
66
104
|
RowDefSorter.prototype.setContext = function(key, value) {
|
67
|
-
this.
|
105
|
+
this._globalContext[key] = value;
|
106
|
+
};
|
107
|
+
/** @public
|
108
|
+
* @param {string} field
|
109
|
+
* @param {Function} logic
|
110
|
+
* @param {boolean} rowSorting
|
111
|
+
* @param {string} order
|
112
|
+
* @param {number} colIndex
|
113
|
+
* @param {*} colDef
|
114
|
+
*/
|
115
|
+
RowDefSorter.prototype.addColumnContext = function(field, logic, rowSorting, order, colIndex, colDef) {
|
116
|
+
if(!field) {
|
117
|
+
field = "";
|
118
|
+
}
|
119
|
+
var sortPriority = this._sortParams.length;
|
120
|
+
var ctx = this._ctxCaches[sortPriority];
|
121
|
+
if(!ctx) {
|
122
|
+
ctx = this._ctxCaches[sortPriority] = cloneObject(this._globalContext);
|
123
|
+
}
|
124
|
+
var orderNum = 0;
|
125
|
+
if(order === "a") {
|
126
|
+
orderNum = 1;
|
127
|
+
} else if(order === "d") {
|
128
|
+
orderNum = -1;
|
129
|
+
}
|
130
|
+
|
131
|
+
var params = [
|
132
|
+
field, // 0
|
133
|
+
(typeof logic === "function") ? logic : null, // 1
|
134
|
+
ctx, // 2
|
135
|
+
rowSorting, // 3
|
136
|
+
orderNum // 4
|
137
|
+
];
|
138
|
+
|
139
|
+
ctx["colIndex"] = colIndex;
|
140
|
+
ctx["field"] = field;
|
141
|
+
ctx["formattedField"] = field + "_FORMATTED";
|
142
|
+
ctx["colDef"] = colDef;
|
143
|
+
|
144
|
+
this._sortParams.push(params);
|
68
145
|
};
|
69
146
|
|
70
147
|
/** @private
|
@@ -73,32 +150,7 @@ RowDefSorter.prototype.setContext = function(key, value) {
|
|
73
150
|
* @param {number} order
|
74
151
|
* @return {number}
|
75
152
|
*/
|
76
|
-
RowDefSorter.
|
77
|
-
var orderA = rowDefA.getGroupOrder();
|
78
|
-
var orderB = rowDefB.getGroupOrder();
|
79
|
-
if(orderA !== orderB) {
|
80
|
-
return orderA - orderB; // Regardless of sort order
|
81
|
-
}
|
82
|
-
|
83
|
-
var a = rowDefA.getData(this._field);
|
84
|
-
var b = rowDefB.getData(this._field);
|
85
|
-
|
86
|
-
if(a == null || a !== a) {
|
87
|
-
if(b == null || b !== b) {
|
88
|
-
return 0;
|
89
|
-
}
|
90
|
-
return 1;
|
91
|
-
}
|
92
|
-
if(b == null || b !== b) {
|
93
|
-
return -1;
|
94
|
-
}
|
95
|
-
|
96
|
-
if(a < b) {
|
97
|
-
return -order;
|
98
|
-
}
|
99
|
-
if(b < a) {
|
100
|
-
return order;
|
101
|
-
}
|
153
|
+
RowDefSorter._noSorting = function(rowDefA, rowDefB, order) {
|
102
154
|
return 0;
|
103
155
|
};
|
104
156
|
/** @private
|
@@ -107,16 +159,30 @@ RowDefSorter.prototype._defaultSorter = function(rowDefA, rowDefB, order) {
|
|
107
159
|
* @param {number} order
|
108
160
|
* @return {number}
|
109
161
|
*/
|
162
|
+
RowDefSorter.prototype._defaultSorter = function(rowDefA, rowDefB, order) {
|
163
|
+
var field = this._primaryParams[0];
|
164
|
+
return _defaultCompare(
|
165
|
+
rowDefA.getData(field),
|
166
|
+
rowDefB.getData(field),
|
167
|
+
order
|
168
|
+
);
|
169
|
+
};
|
170
|
+
/** @private
|
171
|
+
* @param {RowDefinition} rowDefA
|
172
|
+
* @param {RowDefinition} rowDefB
|
173
|
+
* @param {number} order
|
174
|
+
* @return {number}
|
175
|
+
*/
|
110
176
|
RowDefSorter.prototype._dataSorter = function(rowDefA, rowDefB, order) {
|
111
|
-
var
|
112
|
-
var
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
177
|
+
var params = this._primaryParams;
|
178
|
+
var field = params[0];
|
179
|
+
var sortLogic = params[1];
|
180
|
+
return sortLogic(
|
181
|
+
rowDefA.getData(field),
|
182
|
+
rowDefB.getData(field),
|
183
|
+
order,
|
184
|
+
params[2]
|
185
|
+
);
|
120
186
|
};
|
121
187
|
/** @private
|
122
188
|
* @param {RowDefinition} rowDefA
|
@@ -125,13 +191,41 @@ RowDefSorter.prototype._dataSorter = function(rowDefA, rowDefB, order) {
|
|
125
191
|
* @return {number}
|
126
192
|
*/
|
127
193
|
RowDefSorter.prototype._rowDefSorter = function(rowDefA, rowDefB, order) {
|
128
|
-
var
|
129
|
-
var
|
130
|
-
|
131
|
-
|
194
|
+
var params = this._primaryParams;
|
195
|
+
var sortLogic = params[1];
|
196
|
+
return sortLogic(rowDefA, rowDefB, order, params[2]);
|
197
|
+
};
|
198
|
+
/** @private
|
199
|
+
* @param {RowDefinition} rowDefA
|
200
|
+
* @param {RowDefinition} rowDefB
|
201
|
+
* @param {number} primaryOrder
|
202
|
+
* @return {number}
|
203
|
+
*/
|
204
|
+
RowDefSorter.prototype._multiColumnsSorter = function(rowDefA, rowDefB, primaryOrder) {
|
205
|
+
var sortParams = this._sortParams;
|
206
|
+
var sortCount = sortParams.length;
|
207
|
+
for(var i = 0; i < sortCount; ++i) {
|
208
|
+
var params = sortParams[i];
|
209
|
+
var field = params[0];
|
210
|
+
var sortLogic = params[1];
|
211
|
+
var ctx = params[2];
|
212
|
+
var rowSorting = params[3];
|
213
|
+
var orderNum = params[4];
|
214
|
+
var ret = 0;
|
215
|
+
if(sortLogic) {
|
216
|
+
if(rowSorting) {
|
217
|
+
ret = sortLogic(rowDefA, rowDefB, orderNum, ctx);
|
218
|
+
} else {
|
219
|
+
ret = sortLogic(rowDefA.getData(field), rowDefB.getData(field), orderNum, ctx);
|
220
|
+
}
|
221
|
+
} else {
|
222
|
+
ret = _defaultCompare(rowDefA.getData(field), rowDefB.getData(field), orderNum);
|
223
|
+
}
|
224
|
+
if(ret) {
|
225
|
+
return ret;
|
226
|
+
}
|
132
227
|
}
|
133
|
-
|
134
|
-
return this._sortLogic(rowDefA, rowDefB, order, this._sortContext);
|
228
|
+
return 0;
|
135
229
|
};
|
136
230
|
|
137
231
|
export default RowDefSorter;
|
@@ -38,6 +38,8 @@ var ColumnSelectionPlugin = function ColumnSelectionPlugin(options) {
|
|
38
38
|
t._onReselection = t._onReselection.bind(t);
|
39
39
|
t._onThemeLoaded = t._onThemeLoaded.bind(t);
|
40
40
|
t._onColumnPositionChanged = t._onColumnPositionChanged.bind(t);
|
41
|
+
t._onBeforeBatchOperation = t._onBeforeBatchOperation.bind(t);
|
42
|
+
t._onAfterBatchOperation = t._onAfterBatchOperation.bind(t);
|
41
43
|
t._updateMenuIcon = t._updateMenuIcon.bind(t);
|
42
44
|
t._hosts = [];
|
43
45
|
|
@@ -121,6 +123,12 @@ ColumnSelectionPlugin.prototype._menuPosition = "outside";
|
|
121
123
|
|
122
124
|
ColumnSelectionPlugin.prototype._cgp = null; // Column grouping extension
|
123
125
|
|
126
|
+
/** @type {Array.<string>}
|
127
|
+
* @private
|
128
|
+
*/
|
129
|
+
|
130
|
+
ColumnSelectionPlugin.prototype._prevSelectedCols = {}; // previous selected columns during batch operation
|
131
|
+
|
124
132
|
/** @public
|
125
133
|
* @return {string}
|
126
134
|
*/
|
@@ -156,6 +164,8 @@ ColumnSelectionPlugin.prototype.initialize = function (host, options) {
|
|
156
164
|
host.listen("columnRemoved", this._onColumnRemoved);
|
157
165
|
host.listen("columnAdded", this._onColumnAdded);
|
158
166
|
host.listen("columnPositionChanged", this._onColumnPositionChanged);
|
167
|
+
host.listen("beforeBatchOperation", this._onBeforeBatchOperation);
|
168
|
+
host.listen("afterBatchOperation", this._onAfterBatchOperation);
|
159
169
|
this.config(options);
|
160
170
|
|
161
171
|
if (ColumnSelectionPlugin._stylePromise) {
|
@@ -1098,6 +1108,62 @@ ColumnSelectionPlugin.prototype._onReselection = function (e) {
|
|
1098
1108
|
this._activeGrid.focus();
|
1099
1109
|
};
|
1100
1110
|
/** @private
|
1111
|
+
* @param {Object} e
|
1112
|
+
*/
|
1113
|
+
|
1114
|
+
|
1115
|
+
ColumnSelectionPlugin.prototype._onBeforeBatchOperation = function (e) {
|
1116
|
+
var host = this._activeGrid;
|
1117
|
+
|
1118
|
+
if (this._hasSelection && e["batchType"] === "reset") {
|
1119
|
+
var colCount = this.getColumnCount();
|
1120
|
+
|
1121
|
+
for (var i = 0; i < colCount; ++i) {
|
1122
|
+
if (this.isSelectedColumn(i)) {
|
1123
|
+
var colId = host.getColumnId(i);
|
1124
|
+
var field = host.getColumnField(i);
|
1125
|
+
|
1126
|
+
if (colId) {
|
1127
|
+
this._prevSelectedCols[colId] = field;
|
1128
|
+
} else {
|
1129
|
+
this._prevSelectedCols[field] = "";
|
1130
|
+
}
|
1131
|
+
}
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
this.clearAllSelections(); //clear all to improve performance during add/remove operation
|
1135
|
+
}
|
1136
|
+
};
|
1137
|
+
/** @private
|
1138
|
+
* @param {Object} e
|
1139
|
+
*/
|
1140
|
+
|
1141
|
+
|
1142
|
+
ColumnSelectionPlugin.prototype._onAfterBatchOperation = function (e) {
|
1143
|
+
if (e["batchType"] === "reset") {
|
1144
|
+
var prevSelectedCols = Object.keys(this._prevSelectedCols);
|
1145
|
+
var prevSelectedCount = prevSelectedCols.length;
|
1146
|
+
|
1147
|
+
if (prevSelectedCount) {
|
1148
|
+
this.clearAllSelections();
|
1149
|
+
|
1150
|
+
for (var i = 0; i < prevSelectedCount; i++) {
|
1151
|
+
var colId = prevSelectedCols[i];
|
1152
|
+
var field = this._prevSelectedCols[colId];
|
1153
|
+
var prevSelectedIndex = this.getColumnIndex(colId);
|
1154
|
+
|
1155
|
+
if (prevSelectedIndex < 0) {
|
1156
|
+
prevSelectedIndex = this.getColumnIndex(field);
|
1157
|
+
}
|
1158
|
+
|
1159
|
+
this.setSelectedColumn(prevSelectedIndex, true);
|
1160
|
+
}
|
1161
|
+
|
1162
|
+
this._prevSelectedCols = {};
|
1163
|
+
}
|
1164
|
+
}
|
1165
|
+
};
|
1166
|
+
/** @private
|
1101
1167
|
* @param {KeyboardEvent} e
|
1102
1168
|
* @return {boolean}
|
1103
1169
|
*/
|
@@ -3,6 +3,7 @@ import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
|
|
3
3
|
import { Conflator } from "../../tr-grid-util/es6/Conflator.js";
|
4
4
|
import { Icon } from "../../tr-grid-util/es6/Icon.js";
|
5
5
|
import { ElfUtil } from "../../tr-grid-util/es6/ElfUtil.js";
|
6
|
+
import { GroupDefinitions } from "../../tr-grid-util/es6/GroupDefinitions.js";
|
6
7
|
import { Dom } from "../../tr-grid-util/es6/Dom.js";
|
7
8
|
import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
|
8
9
|
import { preventDefault } from "../../tr-grid-util/es6/EventDispatcher.js";
|
@@ -137,6 +138,8 @@ declare class ColumnStackPlugin extends GridPlugin {
|
|
137
138
|
|
138
139
|
public isStackHidden(stackId: string): boolean|null|null;
|
139
140
|
|
141
|
+
public moveStack(stackId: string, destCol?: (number|string)|null): boolean;
|
142
|
+
|
140
143
|
}
|
141
144
|
|
142
145
|
export default ColumnStackPlugin;
|