@refinitiv-ui/efx-grid 6.0.84 → 6.0.86
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/core/dist/core.js +241 -153
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/DataView.d.ts +4 -0
- package/lib/core/es6/data/DataView.js +23 -0
- package/lib/core/es6/grid/Core.d.ts +0 -4
- package/lib/core/es6/grid/Core.js +34 -22
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.d.ts +13 -3
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +184 -131
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +275 -159
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/ColumnDefinition.js +1 -2
- package/lib/rt-grid/es6/Grid.js +7 -7
- package/lib/tr-grid-checkbox/es6/Checkbox.d.ts +2 -0
- package/lib/tr-grid-checkbox/es6/Checkbox.js +38 -0
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +3 -4
- package/lib/tr-grid-filter-input/es6/FilterInput.js +32 -3
- package/lib/tr-grid-row-filtering/es6/RowFiltering.d.ts +4 -1
- package/lib/tr-grid-row-filtering/es6/RowFiltering.js +3 -0
- package/lib/tr-grid-textformatting/es6/TextFormatting.js +13 -2
- package/lib/tr-grid-util/es6/Dom.d.ts +1 -1
- package/lib/tr-grid-util/es6/Dom.js +1 -1
- package/lib/tr-grid-util/es6/ExpressionParser.js +1 -1
- package/lib/tr-grid-util/es6/FieldFormatter.js +4 -2
- package/lib/tr-grid-util/es6/FilterBuilder.d.ts +1 -1
- package/lib/tr-grid-util/es6/FilterBuilder.js +1 -1
- package/lib/tr-grid-util/es6/NumberFormatter.js +2 -2
- package/lib/tr-grid-util/es6/PercentBar.d.ts +1 -1
- package/lib/tr-grid-util/es6/PercentBar.js +1 -1
- package/lib/tr-grid-util/es6/RangeBar.d.ts +1 -1
- package/lib/tr-grid-util/es6/RangeBar.js +8 -7
- package/lib/tr-grid-util/es6/TextHighlighter.d.ts +0 -2
- package/lib/tr-grid-util/es6/TextHighlighter.js +1 -6
- package/lib/tr-grid-util/es6/formula/Formula.js +1 -1
- package/lib/tr-grid-util/es6/formula/VariableToken.js +1 -1
- package/lib/tr-grid-util/es6/formula/functions/Excel.d.ts +1 -1
- package/lib/tr-grid-util/es6/formula/functions/Excel.js +1 -1
- package/lib/tr-grid-util/es6/index.js +1 -1
- package/lib/tr-grid-util/es6/jet/DataGenerator.d.ts +1 -1
- package/lib/tr-grid-util/es6/jet/DataGenerator.js +1 -1
- package/lib/types/es6/Core/data/DataView.d.ts +4 -0
- package/lib/types/es6/Core/grid/Core.d.ts +0 -4
- package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +13 -3
- package/lib/types/es6/RowFiltering.d.ts +4 -1
- package/lib/versions.json +6 -6
- package/package.json +1 -1
@@ -79,16 +79,26 @@ Ext.inherits(SortableTitlePlugin, EventDispatcher);
|
|
79
79
|
* @typedef {"a" | "ascending" | "d" | "descending" | "n" | null} SortableTitlePlugin~SortOrder
|
80
80
|
*/
|
81
81
|
|
82
|
-
/**
|
82
|
+
/** An object that specifies how sorting should be performed
|
83
83
|
* @typedef {Object} SortableTitlePlugin~InitialSort
|
84
|
-
* @property {number=} colIndex
|
85
|
-
* @property {string=} colId
|
86
|
-
* @property {string=} field
|
84
|
+
* @property {number=} colIndex Column index of a column to be sorted
|
85
|
+
* @property {string=} colId Column id of a column to be sorted
|
86
|
+
* @property {string=} field Field of a column to be sorted
|
87
87
|
* @property {SortableTitlePlugin~SortOrder=} sortOrder=null Set to "d" for descending order and "a" for ascending order
|
88
|
-
* @property {SortableTitlePlugin~SortOrder=} order Alias
|
88
|
+
* @property {SortableTitlePlugin~SortOrder=} order Alias to sortOrder
|
89
89
|
*/
|
90
90
|
SortableTitlePlugin.InitialSort;
|
91
91
|
|
92
|
+
/** An object that specifies how sorting should be performed
|
93
|
+
* @typedef {Object} SortableTitlePlugin~SortingDefinition
|
94
|
+
* @property {number=} colIndex Column index of a column to be sorted
|
95
|
+
* @property {string=} colId Column id of a column to be sorted
|
96
|
+
* @property {string=} field Field of a column to be sorted
|
97
|
+
* @property {SortableTitlePlugin~SortOrder=} sortOrder=null Set to "d" for descending order and "a" for ascending order
|
98
|
+
* @property {SortableTitlePlugin~SortOrder=} order Alias to sortOrder
|
99
|
+
*/
|
100
|
+
SortableTitlePlugin.SortingDefinition;
|
101
|
+
|
92
102
|
/** The sorting properties for column option.
|
93
103
|
* @typedef {Object} SortableTitlePlugin~ColumnOptions
|
94
104
|
* @property {boolean=} sortable=false If enable, the column can be sorted by user click
|
@@ -104,7 +114,7 @@ SortableTitlePlugin.ColumnOptions;
|
|
104
114
|
|
105
115
|
/** The configuration object for sorting options. This can be defined by `sorting` property in CompositeGrid configuration object.
|
106
116
|
* @typedef {Object} SortableTitlePlugin~Options
|
107
|
-
* @property {(SortableTitlePlugin~InitialSort|Array.<SortableTitlePlugin.
|
117
|
+
* @property {(SortableTitlePlugin~InitialSort|Array.<SortableTitlePlugin.SortingDefinition>)=} initialSort=null Set this config to initiate sorting after grid is created.
|
108
118
|
* @property {(boolean|number)=} multicolumn=false Allow multiple columns to be sorted at the same time. If number is defined, it is treated as maximum number of column to be sorted.
|
109
119
|
* @property {(boolean|number)=} multiColumn=false Alias to `multicolumn`
|
110
120
|
* @property {boolean=} threeStatesSorting=false If enabled, sorting will cycle through ascending, descending and original order states. This option is deprecated in favor of sortingSequence option
|
@@ -164,7 +174,7 @@ SortableTitlePlugin.prototype._delayInterval = 0;
|
|
164
174
|
*/
|
165
175
|
SortableTitlePlugin.prototype._lastMouseDown = 0;
|
166
176
|
/** @private
|
167
|
-
* @type {SortableTitlePlugin.
|
177
|
+
* @type {SortableTitlePlugin.SortingDefinition}
|
168
178
|
*/
|
169
179
|
SortableTitlePlugin.prototype._initialSort = null;
|
170
180
|
/** @private
|
@@ -487,7 +497,8 @@ SortableTitlePlugin.prototype.getConfigObject = function (gridOptions) {
|
|
487
497
|
}
|
488
498
|
field = opt["field"];
|
489
499
|
if (field) {
|
490
|
-
|
500
|
+
// WARNING: When Core's column has no field, sortBy property does not get returned
|
501
|
+
if(col["field"] != null && col["field"] !== field) {
|
491
502
|
col["sortBy"] = field;
|
492
503
|
} // else The default value is an empty sortBy, which refers to the same column field by default.
|
493
504
|
|
@@ -705,18 +716,38 @@ SortableTitlePlugin.prototype.getSortOrder = function (colIndex) {
|
|
705
716
|
* @return {number} Return negative value if there is no sorted column
|
706
717
|
*/
|
707
718
|
SortableTitlePlugin.prototype.getSortedColumnIndex = function (priority) {
|
708
|
-
return this.
|
719
|
+
return this._getColumnIndex(this._sortStates[priority || 0]);
|
709
720
|
};
|
710
721
|
/** Start with 0 (the first column that is being sorted). The highest number will be sorted last. Negative value means the specified column is not sorted
|
711
722
|
* @public
|
712
723
|
* @param {number} colIndex
|
724
|
+
* @param {string=} colRef field or column id
|
713
725
|
* @return {number}
|
714
726
|
*/
|
715
|
-
SortableTitlePlugin.prototype.getSortPriority = function (colIndex) {
|
716
|
-
var
|
717
|
-
|
718
|
-
|
719
|
-
|
727
|
+
SortableTitlePlugin.prototype.getSortPriority = function (colIndex, colRef) {
|
728
|
+
var host = this._hosts[0];
|
729
|
+
if(host) {
|
730
|
+
var i;
|
731
|
+
var len = this._sortStates.length;
|
732
|
+
if(colIndex >= 0) {
|
733
|
+
var colId = host.getColumnId(colIndex);
|
734
|
+
if(colId) {
|
735
|
+
for(i = 0; i < len; ++i) {
|
736
|
+
if(this._sortStates[i]["colId"] === colId) {
|
737
|
+
return i;
|
738
|
+
}
|
739
|
+
}
|
740
|
+
}
|
741
|
+
} else if(colRef) {
|
742
|
+
for(i = 0; i < len; ++i) {
|
743
|
+
var sortState = this._sortStates[i];
|
744
|
+
if(sortState["colId"] === colRef) {
|
745
|
+
return i;
|
746
|
+
}
|
747
|
+
if(sortState["field"] === colRef) {
|
748
|
+
return i;
|
749
|
+
}
|
750
|
+
}
|
720
751
|
}
|
721
752
|
}
|
722
753
|
return -1;
|
@@ -729,7 +760,7 @@ SortableTitlePlugin.prototype.isColumnSorted = function (colIndex) {
|
|
729
760
|
return this.getSortPriority(colIndex) >= 0;
|
730
761
|
};
|
731
762
|
/** @public
|
732
|
-
* @return {Array.<Object>} Array of
|
763
|
+
* @return {Array.<Object>} Array of objects with colIndex, colId, field, and sortOrder properties
|
733
764
|
*/
|
734
765
|
SortableTitlePlugin.prototype.getSortedColumns = function () {
|
735
766
|
var len = this._sortStates.length;
|
@@ -739,12 +770,21 @@ SortableTitlePlugin.prototype.getSortedColumns = function () {
|
|
739
770
|
for (var i = 0; i < len; ++i) {
|
740
771
|
var colIndex = this.getSortedColumnIndex(i);
|
741
772
|
var state = this._sortStates[i];
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
}
|
773
|
+
var retObj = {};
|
774
|
+
var colId = "";
|
775
|
+
if(colIndex >= 0) {
|
776
|
+
retObj["colIndex"] = colIndex;
|
777
|
+
colId = this._getColumnId(colIndex);
|
778
|
+
}
|
779
|
+
if(colId) {
|
780
|
+
retObj["colId"] = colId;
|
781
|
+
}
|
782
|
+
var field = state["field"] || "";
|
783
|
+
if(field) {
|
784
|
+
retObj["field"] = field;
|
785
|
+
}
|
786
|
+
retObj["sortOrder"] = state["sortOrder"] || "n";
|
787
|
+
arr[i] = retObj;
|
748
788
|
}
|
749
789
|
return arr;
|
750
790
|
};
|
@@ -763,35 +803,22 @@ SortableTitlePlugin.prototype.isSorting = function () {
|
|
763
803
|
* @fires SortableTitlePlugin#columnSorted
|
764
804
|
*/
|
765
805
|
SortableTitlePlugin.prototype.sortColumn = function (colRef, sortOrder, opt_arg) {
|
766
|
-
|
767
|
-
if (state) {
|
768
|
-
this._sortColumn([state], opt_arg);
|
769
|
-
}
|
806
|
+
this._sortColumn(this._prepareSorting(colRef, sortOrder), opt_arg);
|
770
807
|
};
|
771
808
|
|
772
809
|
/** Sort multiple columns at once
|
773
810
|
* @public
|
774
|
-
* @param {Array.<SortableTitlePlugin.
|
811
|
+
* @param {Array.<SortableTitlePlugin.SortingDefinition>} sortOptions Input an array to specify the multiple column sort order
|
775
812
|
* @param {Object=} opt_arg Event argument to be sent with preDataSorting event
|
776
813
|
* @fires SortableTitlePlugin#preDataSorting
|
777
814
|
* @fires SortableTitlePlugin#columnSorted
|
778
815
|
*/
|
779
816
|
SortableTitlePlugin.prototype.sortColumns = function (sortOptions, opt_arg) {
|
780
817
|
if (Array.isArray(sortOptions)) {
|
781
|
-
var
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
if(colRef == null) {
|
786
|
-
colRef = opt["colIndex"];
|
787
|
-
}
|
788
|
-
var state = this._prepareSorting(
|
789
|
-
colRef,
|
790
|
-
opt["sortOrder"] || opt["order"]
|
791
|
-
);
|
792
|
-
if (state) {
|
793
|
-
states.push(state);
|
794
|
-
}
|
818
|
+
var len = sortOptions.length;
|
819
|
+
var states = new Array(len);
|
820
|
+
for (var i = 0; i < len; i++) {
|
821
|
+
states[i] = this._prepareSorting(sortOptions[i]);
|
795
822
|
}
|
796
823
|
this._sortColumn(states, opt_arg);
|
797
824
|
}
|
@@ -892,7 +919,10 @@ SortableTitlePlugin.prototype.getColumnSortingField = function (colIndex) {
|
|
892
919
|
if (field == null && !this._rowDefMode) { // Old CompositeGrid may store sorting field in DataColumnName
|
893
920
|
var host = this._hosts[0];
|
894
921
|
if (host) {
|
895
|
-
field = host.
|
922
|
+
field = host.getColumnField(colIndex);
|
923
|
+
if(!field) {
|
924
|
+
field = host.getDataColumnName(colIndex);
|
925
|
+
}
|
896
926
|
if(field && sortOptions) {
|
897
927
|
sortOptions["field"] = field; // Cache for later use
|
898
928
|
}
|
@@ -927,28 +957,20 @@ SortableTitlePlugin.prototype.setColumnSortingField = function (colIndex, field,
|
|
927
957
|
}
|
928
958
|
}
|
929
959
|
};
|
960
|
+
|
961
|
+
/** @private
|
962
|
+
* @param {Object} sortState
|
963
|
+
* @returns {string}
|
964
|
+
*/
|
965
|
+
var _toField = function(sortState) {
|
966
|
+
return sortState["field"] || "";
|
967
|
+
};
|
930
968
|
/** Return array of the fields from the currently sorted columns
|
931
969
|
* @public
|
932
970
|
* @return {!Array.<string>} fields of each sorting states
|
933
971
|
*/
|
934
972
|
SortableTitlePlugin.prototype.getColumnSortingFields = function () {
|
935
|
-
|
936
|
-
var ary = new Array(len);
|
937
|
-
var host = this._hosts[0];
|
938
|
-
|
939
|
-
for(var i = 0; i < len; ++i) {
|
940
|
-
var sortOptions = this._sortStates[i];
|
941
|
-
var field = sortOptions["field"];
|
942
|
-
if(!field && !this._rowDefMode) {
|
943
|
-
var colIndex = this._getColumnIndexByOptions(sortOptions); // Slow
|
944
|
-
field = host.getDataColumnName(colIndex);
|
945
|
-
if(field) {
|
946
|
-
sortOptions["field"] = field; // Cache for later use
|
947
|
-
}
|
948
|
-
}
|
949
|
-
ary[i] = field || "";
|
950
|
-
}
|
951
|
-
return ary;
|
973
|
+
return this._sortStates.map(_toField);
|
952
974
|
};
|
953
975
|
|
954
976
|
/** This is deprecated in favor of setSortingSequence method. Move existing sort order to the front of sorting sequence. New sort order will be added, if the specified sort order does not exist in current sorting sequence.
|
@@ -957,7 +979,6 @@ SortableTitlePlugin.prototype.getColumnSortingFields = function () {
|
|
957
979
|
* @param {string=} sortOrder="a" "ascending", "descending", "none"
|
958
980
|
* @see {@link SortableTitlePlugin#setSortingSequence}
|
959
981
|
*/
|
960
|
-
|
961
982
|
SortableTitlePlugin.prototype.setFirstSortOrder = function (colIdentifier, sortOrder) {
|
962
983
|
if (sortOrder) {
|
963
984
|
sortOrder = SortableTitlePlugin._toSortOrder(sortOrder);
|
@@ -1175,10 +1196,8 @@ SortableTitlePlugin.prototype._proceedSorting = function (hitObj) {
|
|
1175
1196
|
if (this._canClickToSort(hitObj)) {
|
1176
1197
|
var colIndex = hitObj["colIndex"];
|
1177
1198
|
// _proceedSorting() method is always produced by user clicking at the header // Thus, this operation is guaranteed to be a user action
|
1178
|
-
|
1179
|
-
|
1180
|
-
this._sortColumn([state], { "isUserAction": true });
|
1181
|
-
}
|
1199
|
+
this.sortColumn(colIndex, null, { "isUserAction": true });
|
1200
|
+
|
1182
1201
|
var grid = hitObj["grid"];
|
1183
1202
|
if(grid && grid["focus"]) {
|
1184
1203
|
grid["focus"]();
|
@@ -1188,7 +1207,7 @@ SortableTitlePlugin.prototype._proceedSorting = function (hitObj) {
|
|
1188
1207
|
var ce = {};
|
1189
1208
|
ce["colIndex"] = colIndex;
|
1190
1209
|
ce["sortOrder"] = this.getSortOrder(colIndex);
|
1191
|
-
ce["dataColumnName"] = this.getColumnSortingField(colIndex);
|
1210
|
+
ce["dataColumnName"] = this.getColumnSortingField(colIndex); // This should be deprecated
|
1192
1211
|
this._dispatch("clicked", ce);
|
1193
1212
|
}
|
1194
1213
|
}
|
@@ -1378,7 +1397,7 @@ SortableTitlePlugin.prototype.sortSeparators = function (comparer) {
|
|
1378
1397
|
var sortStateCount = this._sortStates.length;
|
1379
1398
|
var rowDefField = SortableTitlePlugin._toRowDefField();
|
1380
1399
|
for(var i = 0; i < sortStateCount; i++){
|
1381
|
-
var sortState =
|
1400
|
+
var sortState = this._sortStates[i];
|
1382
1401
|
var field = this._rowDefMode ? rowDefField : sortState["field"];
|
1383
1402
|
sortOrders.push(sortState["sortOrder"]);
|
1384
1403
|
sortFields.push(field);
|
@@ -1389,19 +1408,51 @@ SortableTitlePlugin.prototype.sortSeparators = function (comparer) {
|
|
1389
1408
|
|
1390
1409
|
|
1391
1410
|
/** @private
|
1392
|
-
* @param {number|string}
|
1411
|
+
* @param {(number|string|SortableTitlePlugin.SortingDefinition)} sortingDef This could be column index, field, or SortingDefinition
|
1393
1412
|
* @param {string=} sortOrder "a" for ascending, "d" for descending, and "n" for no sorting
|
1394
1413
|
* @returns {Object} state Returns null, if nothing is changed
|
1395
1414
|
*/
|
1396
|
-
SortableTitlePlugin.prototype._prepareSorting = function (
|
1415
|
+
SortableTitlePlugin.prototype._prepareSorting = function (sortingDef, sortOrder) {
|
1397
1416
|
if (!this._maxCount) {
|
1398
1417
|
return null;
|
1399
1418
|
}
|
1419
|
+
var host = this._hosts[0];
|
1420
|
+
if(!host) {
|
1421
|
+
return null;
|
1422
|
+
}
|
1423
|
+
|
1424
|
+
var colIndex = -1;
|
1425
|
+
var colRef = "";
|
1426
|
+
if(typeof sortingDef === "number") {
|
1427
|
+
colIndex = sortingDef;
|
1428
|
+
} else if(typeof sortingDef === "string") { // This would be either column id or field
|
1429
|
+
colRef = sortingDef;
|
1430
|
+
colIndex = this._getColumnIndex(colRef);
|
1431
|
+
} else if(sortingDef && typeof sortingDef === "object") {
|
1432
|
+
colRef = sortingDef["colId"] || sortingDef["field"];
|
1433
|
+
if(colRef) {
|
1434
|
+
colIndex = this._getColumnIndex(colRef);
|
1435
|
+
} else if(typeof sortingDef["colIndex"] === "number") {
|
1436
|
+
colIndex = sortingDef["colIndex"];
|
1437
|
+
}
|
1438
|
+
if(!sortOrder) {
|
1439
|
+
sortOrder = sortingDef["sortOrder"] || sortingDef["order"] || null;
|
1440
|
+
}
|
1441
|
+
}
|
1400
1442
|
|
1401
|
-
var
|
1402
|
-
var
|
1403
|
-
|
1443
|
+
var field = "";
|
1444
|
+
var sortLogic = null;
|
1445
|
+
if(colIndex >= 0) {
|
1446
|
+
field = this.getColumnSortingField(colIndex);
|
1447
|
+
var sortOptions = this._getSortOptions(colIndex);
|
1448
|
+
if(sortOptions) {
|
1449
|
+
sortLogic = sortOptions["sortLogic"];
|
1450
|
+
}
|
1451
|
+
} else if(colRef) {
|
1452
|
+
field = colRef; // Assume that colRef is a field and not a column id
|
1453
|
+
}
|
1404
1454
|
|
1455
|
+
var priority = this.getSortPriority(colIndex, field);
|
1405
1456
|
var curState = (priority >= 0) ? this._sortStates[priority] : null;
|
1406
1457
|
var curOrder = curState ? curState["sortOrder"] : "n";
|
1407
1458
|
|
@@ -1429,7 +1480,6 @@ SortableTitlePlugin.prototype._prepareSorting = function (colRef, sortOrder) {
|
|
1429
1480
|
|
1430
1481
|
this._sortStates.splice(priority, 1); // Remove sort states
|
1431
1482
|
this._clearSortSymbols(curState); // Clear any previous symbols
|
1432
|
-
// TODO: Other states in curState should be cleared as it is actually a sortOptions object
|
1433
1483
|
}
|
1434
1484
|
|
1435
1485
|
if (nextOrder === "a" || nextOrder === "d") { // Reorder sort states
|
@@ -1437,12 +1487,14 @@ SortableTitlePlugin.prototype._prepareSorting = function (colRef, sortOrder) {
|
|
1437
1487
|
return null;
|
1438
1488
|
}
|
1439
1489
|
if (!curState) {
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1490
|
+
curState = {};
|
1491
|
+
var colId = host.getColumnId(colIndex);
|
1492
|
+
if(colId) {
|
1493
|
+
curState["colId"] = colId;
|
1494
|
+
}
|
1445
1495
|
}
|
1496
|
+
curState["field"] = field;
|
1497
|
+
curState["sortLogic"] = sortLogic || null;
|
1446
1498
|
|
1447
1499
|
this._sortStates.push(curState); // Latest sorting have lowest priority (multiColumn sorting)
|
1448
1500
|
}
|
@@ -1477,31 +1529,47 @@ SortableTitlePlugin.prototype._prepareSorting = function (colRef, sortOrder) {
|
|
1477
1529
|
};
|
1478
1530
|
|
1479
1531
|
/** @private
|
1480
|
-
* @param {Array.<Object>} states States from _prepareSorting for dispatching columnSorted event.
|
1532
|
+
* @param {Object|Array.<Object>} states States from _prepareSorting for dispatching columnSorted event.
|
1481
1533
|
* @param {Object=} opt_arg Event argument to be sent with preDataSorting event
|
1482
1534
|
* @fires SortableTitlePlugin#preDataSorting
|
1483
1535
|
* @fires SortableTitlePlugin#columnSorted
|
1484
1536
|
*/
|
1485
1537
|
SortableTitlePlugin.prototype._sortColumn = function (states, opt_arg) {
|
1538
|
+
if(!states) {
|
1539
|
+
return;
|
1540
|
+
}
|
1541
|
+
|
1486
1542
|
this._sortDataView(opt_arg); // Update Data
|
1487
1543
|
this.updateSortSymbols(); // Update Display
|
1488
1544
|
|
1489
|
-
var
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1545
|
+
var evtArg = null;
|
1546
|
+
if(Array.isArray(states)) {
|
1547
|
+
var len = states.length;
|
1548
|
+
for(var i = 0; i < len; ++i) {
|
1549
|
+
var state = states[i];
|
1550
|
+
if(state) {
|
1551
|
+
if(evtArg) {
|
1552
|
+
if(!evtArg["colIndices"]) {
|
1553
|
+
evtArg["colIndices"] = [];
|
1554
|
+
evtArg["sortedFields"] = [];
|
1555
|
+
evtArg["sortOrders"] = [];
|
1556
|
+
evtArg["prevOrders"] = [];
|
1557
|
+
}
|
1558
|
+
|
1559
|
+
evtArg["colIndices"].push(state["colIndex"]);
|
1560
|
+
evtArg["sortedFields"].push(state["sortedField"]);
|
1561
|
+
evtArg["sortOrders"].push(state["sortOrder"]);
|
1562
|
+
evtArg["prevOrders"].push(state["prevOrder"]);
|
1563
|
+
} else {
|
1564
|
+
evtArg = state;
|
1565
|
+
}
|
1566
|
+
}
|
1502
1567
|
}
|
1568
|
+
evtArg = states[0];
|
1569
|
+
} else {
|
1570
|
+
evtArg = states;
|
1503
1571
|
}
|
1504
|
-
this._dispatch("columnSorted",
|
1572
|
+
this._dispatch("columnSorted", evtArg);
|
1505
1573
|
};
|
1506
1574
|
|
1507
1575
|
/** @private
|
@@ -1559,24 +1627,23 @@ SortableTitlePlugin.prototype._onColumnAdded = function (e) {
|
|
1559
1627
|
* @fires SortableTitlePlugin#columnSorted
|
1560
1628
|
*/
|
1561
1629
|
SortableTitlePlugin.prototype._onColumnRemoved = function (e) {
|
1562
|
-
if (!e["atTheMiddle"]) { return; }
|
1563
|
-
|
1564
1630
|
var sortCount = this._sortStates.length;
|
1565
1631
|
if (!sortCount) {
|
1566
1632
|
return;
|
1567
1633
|
}
|
1568
|
-
var
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
//
|
1573
|
-
|
1574
|
-
var
|
1575
|
-
if (
|
1576
|
-
this._sortStates.splice(
|
1634
|
+
var colId = e["colId"];
|
1635
|
+
if (!colId) {
|
1636
|
+
return;
|
1637
|
+
}
|
1638
|
+
// WARNING: columnRemoved event could be fired repeatedly. Sorting could be triggered multiple times
|
1639
|
+
for(var i = 0; i < sortCount; ++i) {
|
1640
|
+
var sortState = this._sortStates[i];
|
1641
|
+
if (sortState["colId"] === colId) {
|
1642
|
+
this._sortStates.splice(i, 1);
|
1643
|
+
this._clearSortSymbols(sortState);
|
1644
|
+
this._sortDataView();
|
1645
|
+
break;
|
1577
1646
|
}
|
1578
|
-
this._clearSortSymbols(sortOptions);
|
1579
|
-
this._sortDataView();
|
1580
1647
|
}
|
1581
1648
|
};
|
1582
1649
|
|
@@ -1670,8 +1737,8 @@ SortableTitlePlugin.prototype._updateSortableIndicator = function (hostIndex) {
|
|
1670
1737
|
|
1671
1738
|
var section = host.getSection("title");
|
1672
1739
|
if (section == null) { return; }
|
1673
|
-
var
|
1674
|
-
for (var col =
|
1740
|
+
var colCount = section["getColumnCount"]();
|
1741
|
+
for (var col = colCount; --col >= 0;) {
|
1675
1742
|
|
1676
1743
|
var rowCount = section["getRowCount"]();
|
1677
1744
|
for (var r = 0; r < rowCount; r++) {
|
@@ -1765,35 +1832,24 @@ SortableTitlePlugin.prototype._createIconElem = function (icon, fallback) {
|
|
1765
1832
|
};
|
1766
1833
|
|
1767
1834
|
/** @private
|
1768
|
-
* @param {Object}
|
1835
|
+
* @param {string|number|Object} colRef This can be sortState, column id, column field, or column index
|
1769
1836
|
* @return {number}
|
1770
1837
|
*/
|
1771
|
-
SortableTitlePlugin.prototype.
|
1772
|
-
if(
|
1838
|
+
SortableTitlePlugin.prototype._getColumnIndex = function (colRef) {
|
1839
|
+
if(colRef != null) {
|
1773
1840
|
var host = this._hosts[0];
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
if
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1841
|
+
if(host) {
|
1842
|
+
if(typeof colRef === "number") {
|
1843
|
+
return colRef;
|
1844
|
+
} else if(typeof colRef === "string") {
|
1845
|
+
return host.getColumnIndex(colRef);
|
1846
|
+
} else {
|
1847
|
+
return host.getColumnIndex(colRef["colId"]);
|
1781
1848
|
}
|
1782
1849
|
}
|
1783
1850
|
}
|
1784
1851
|
return -1;
|
1785
1852
|
};
|
1786
|
-
/** @private
|
1787
|
-
* @param {string|number} colRef
|
1788
|
-
* @return {number}
|
1789
|
-
*/
|
1790
|
-
SortableTitlePlugin.prototype._getColumnIndex = function (colRef) {
|
1791
|
-
var host = this._hosts[0];
|
1792
|
-
if(host && colRef != null) {
|
1793
|
-
return host.getColumnIndex(colRef);
|
1794
|
-
}
|
1795
|
-
return -1;
|
1796
|
-
};
|
1797
1853
|
|
1798
1854
|
/** @private
|
1799
1855
|
* @param {string|number} colRef
|
@@ -1814,10 +1870,7 @@ SortableTitlePlugin.prototype._getColumnId = function (colRef) {
|
|
1814
1870
|
SortableTitlePlugin.prototype._getSortOptions = function (colIndex) {
|
1815
1871
|
var host = this._hosts[0];
|
1816
1872
|
if (host) {
|
1817
|
-
|
1818
|
-
if (colData) {
|
1819
|
-
return colData["sortableTitle"];
|
1820
|
-
}
|
1873
|
+
return host.getColumnData(colIndex)["sortableTitle"] || null;
|
1821
1874
|
}
|
1822
1875
|
return null;
|
1823
1876
|
};
|
package/lib/grid/index.js
CHANGED