@refinitiv-ui/efx-grid 6.0.91 → 6.0.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/column-dragging/es6/ColumnDragging.d.ts +1 -1
- package/lib/column-dragging/es6/ColumnDragging.js +144 -34
- package/lib/core/dist/core.js +2410 -2621
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/ColumnStats.js +14 -14
- package/lib/core/es6/data/DataCache.js +118 -118
- package/lib/core/es6/data/DataTable.d.ts +3 -1
- package/lib/core/es6/data/DataTable.js +208 -190
- package/lib/core/es6/data/DataView.d.ts +1 -1
- package/lib/core/es6/data/DataView.js +291 -291
- package/lib/core/es6/data/Segment.js +79 -79
- package/lib/core/es6/data/SegmentCollection.js +81 -81
- package/lib/core/es6/data/WrappedView.js +41 -41
- package/lib/core/es6/grid/Core.js +635 -635
- package/lib/core/es6/grid/ILayoutGrid.js +1 -1
- package/lib/core/es6/grid/LayoutGrid.js +183 -183
- package/lib/core/es6/grid/VirtualizedLayoutGrid.js +91 -91
- package/lib/core/es6/grid/components/Cell.js +29 -29
- package/lib/core/es6/grid/components/CellFloatingPanel.js +11 -11
- package/lib/core/es6/grid/components/CellSpan.js +7 -7
- package/lib/core/es6/grid/components/CellSpans.js +36 -34
- package/lib/core/es6/grid/components/Column.js +40 -40
- package/lib/core/es6/grid/components/ElementWrapper.js +17 -17
- package/lib/core/es6/grid/components/HScrollbar.js +31 -31
- package/lib/core/es6/grid/components/Scrollbar.js +77 -77
- package/lib/core/es6/grid/components/StretchedCells.js +49 -49
- package/lib/core/es6/grid/components/VScrollbar.js +11 -11
- package/lib/core/es6/grid/components/VirtualItems.js +3 -3
- package/lib/core/es6/grid/event/EventDispatcher.js +9 -9
- package/lib/core/es6/grid/event/EventListeners.js +4 -4
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +186 -186
- package/lib/core/es6/grid/util/Conflator.js +4 -4
- package/lib/core/es6/grid/util/Reverter.js +1 -1
- package/lib/core/es6/grid/util/SectionSettings.js +20 -20
- package/lib/core/es6/grid/util/SelectionList.js +23 -23
- package/lib/core/es6/grid/util/TrackLayout.js +74 -74
- package/lib/core/es6/grid/util/Virtualizer.js +15 -15
- package/lib/core/es6/grid/util/util.js +20 -20
- package/lib/core/es6/index.d.ts +0 -2
- package/lib/core/es6/index.js +0 -3
- package/lib/filter-dialog/lib/filter-dialog.js +1 -0
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +193 -70
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.js +46 -30
- package/lib/rt-grid/es6/RowDefinition.d.ts +2 -1
- package/lib/rt-grid/es6/RowDefinition.js +74 -16
- package/lib/tr-grid-cell-selection/es6/CellSelection.js +56 -1
- package/lib/tr-grid-checkbox/es6/Checkbox.js +268 -268
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +3 -2
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +60 -32
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +279 -279
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +227 -207
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +11 -11
- package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +1 -2
- package/lib/tr-grid-row-dragging/es6/RowDragging.js +120 -121
- package/lib/tr-grid-util/es6/CellPainter.js +94 -104
- package/lib/tr-grid-util/es6/Conflator.js +4 -4
- package/lib/tr-grid-util/es6/CoralItems.js +6 -6
- package/lib/tr-grid-util/es6/DateTime.js +41 -41
- package/lib/tr-grid-util/es6/Deferred.js +5 -5
- package/lib/tr-grid-util/es6/Delay.d.ts +3 -3
- package/lib/tr-grid-util/es6/Delay.js +14 -3
- package/lib/tr-grid-util/es6/Dom.js +26 -26
- package/lib/tr-grid-util/es6/DragUI.js +17 -17
- package/lib/tr-grid-util/es6/ElementObserver.js +12 -12
- package/lib/tr-grid-util/es6/ElementWrapper.js +2 -2
- package/lib/tr-grid-util/es6/ElfDate.js +4 -4
- package/lib/tr-grid-util/es6/ElfUtil.js +37 -37
- package/lib/tr-grid-util/es6/EventDispatcher.js +12 -12
- package/lib/tr-grid-util/es6/ExpanderIcon.js +6 -6
- package/lib/tr-grid-util/es6/ExpressionParser.js +43 -43
- package/lib/tr-grid-util/es6/Ext.js +6 -6
- package/lib/tr-grid-util/es6/FieldFormatter.js +17 -17
- package/lib/tr-grid-util/es6/FilterBuilder.js +57 -58
- package/lib/tr-grid-util/es6/FilterOperators.d.ts +12 -1
- package/lib/tr-grid-util/es6/FilterOperators.js +13 -2
- package/lib/tr-grid-util/es6/GridPlugin.js +86 -87
- package/lib/tr-grid-util/es6/GroupDefinitions.js +90 -90
- package/lib/tr-grid-util/es6/Icon.js +4 -4
- package/lib/tr-grid-util/es6/MouseDownTrait.js +6 -6
- package/lib/tr-grid-util/es6/MultiTableManager.js +71 -80
- package/lib/tr-grid-util/es6/NumberFormatter.js +23 -23
- package/lib/tr-grid-util/es6/PercentBar.js +17 -17
- package/lib/tr-grid-util/es6/Perf.js +5 -5
- package/lib/tr-grid-util/es6/Popup.js +42 -42
- package/lib/tr-grid-util/es6/RangeBar.js +5 -5
- package/lib/tr-grid-util/es6/RequestQueue.js +5 -5
- package/lib/tr-grid-util/es6/RowPainter.js +23 -23
- package/lib/tr-grid-util/es6/SubTable.js +94 -94
- package/lib/tr-grid-util/es6/Table.js +51 -51
- package/lib/tr-grid-util/es6/TextHighlighter.js +52 -52
- package/lib/tr-grid-util/es6/TickCodes.js +2 -2
- package/lib/tr-grid-util/es6/Timer.js +2 -2
- package/lib/tr-grid-util/es6/TouchProxy.js +7 -7
- package/lib/tr-grid-util/es6/Util.js +50 -50
- package/lib/tr-grid-util/es6/formula/ADCService.js +2 -2
- package/lib/tr-grid-util/es6/formula/ADCSubscription.js +19 -19
- package/lib/tr-grid-util/es6/formula/AdFinService.js +2 -2
- package/lib/tr-grid-util/es6/formula/AdFinSubscription.js +19 -19
- package/lib/tr-grid-util/es6/formula/Engine.js +56 -56
- package/lib/tr-grid-util/es6/formula/Formula.js +62 -62
- package/lib/tr-grid-util/es6/formula/IntervalSubscription.js +3 -3
- package/lib/tr-grid-util/es6/formula/Realtime.js +15 -15
- package/lib/tr-grid-util/es6/formula/RealtimeService.js +15 -15
- package/lib/tr-grid-util/es6/formula/TSIService.js +2 -2
- package/lib/tr-grid-util/es6/formula/TSISubscription.js +104 -104
- package/lib/tr-grid-util/es6/formula/VariableToken.js +20 -20
- package/lib/tr-grid-util/es6/formula/functions/AdFin.js +10 -10
- package/lib/tr-grid-util/es6/formula/functions/Excel.js +1 -1
- package/lib/tr-grid-util/es6/formula/functions/Info.js +2 -2
- package/lib/tr-grid-util/es6/formula/functions/Internal.js +5 -5
- package/lib/tr-grid-util/es6/formula/functions/Logic.js +5 -5
- package/lib/tr-grid-util/es6/formula/functions/Math.js +46 -46
- package/lib/tr-grid-util/es6/formula/functions/Statistics.js +27 -27
- package/lib/tr-grid-util/es6/formula/functions/Text.js +19 -19
- package/lib/tr-grid-util/es6/index.js +1 -1
- package/lib/tr-grid-util/es6/jet/Adc.js +36 -36
- package/lib/tr-grid-util/es6/jet/CollectionDict.js +11 -11
- package/lib/tr-grid-util/es6/jet/DataGenerator.js +95 -95
- package/lib/tr-grid-util/es6/jet/DataSet.js +1 -1
- package/lib/tr-grid-util/es6/jet/MockArchive.js +5 -5
- package/lib/tr-grid-util/es6/jet/MockJET.js +1 -1
- package/lib/tr-grid-util/es6/jet/MockQuotes.js +13 -13
- package/lib/tr-grid-util/es6/jet/MockQuotes2.js +100 -100
- package/lib/tr-grid-util/es6/jet/MockRTK.js +4 -4
- package/lib/tr-grid-util/es6/jet/MockUtil.js +2 -2
- package/lib/tr-grid-util/es6/jet/index.js +1 -1
- package/lib/tr-grid-util/es6/jet/mockDataAPI.js +15 -15
- package/lib/tr-grid-util/es6/locale/translation-de.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-en.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-ja.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-zh-hant.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-zh.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation.js +1 -1
- package/lib/types/es6/ColumnDragging.d.ts +1 -1
- package/lib/types/es6/ColumnGrouping.d.ts +3 -1
- package/lib/types/es6/Core/data/DataTable.d.ts +4 -0
- package/lib/types/es6/Core/data/DataView.d.ts +2 -0
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +2 -0
- package/lib/types/es6/Core/index.d.ts +0 -2
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +2 -1
- package/lib/types/es6/RowDragging.d.ts +1 -2
- package/lib/versions.json +12 -12
- package/package.json +1 -1
- package/lib/core/es6/grid/util/ElementFrameWork.d.ts +0 -18
- package/lib/core/es6/grid/util/ElementFrameWork.js +0 -227
- package/lib/core/es6/grid/util/HttpRequest.d.ts +0 -53
- package/lib/core/es6/grid/util/HttpRequest.js +0 -371
- package/lib/core/es6/grid/util/PercentBar.d.ts +0 -43
- package/lib/core/es6/grid/util/PercentBar.js +0 -390
- package/lib/core/es6/grid/util/PercentBarRenderer.d.ts +0 -41
- package/lib/core/es6/grid/util/PercentBarRenderer.js +0 -316
- package/lib/core/es6/grid/util/RangeBar.d.ts +0 -25
- package/lib/core/es6/grid/util/RangeBar.js +0 -255
- package/lib/types/es6/Core/grid/util/ElementFrameWork.d.ts +0 -18
- package/lib/types/es6/Core/grid/util/HttpRequest.d.ts +0 -53
- package/lib/types/es6/Core/grid/util/PercentBar.d.ts +0 -43
- package/lib/types/es6/Core/grid/util/PercentBarRenderer.d.ts +0 -41
- package/lib/types/es6/Core/grid/util/RangeBar.d.ts +0 -25
|
@@ -44,8 +44,8 @@ import { isEmptyObject } from "../../../../tr-grid-util/es6/Util.js";
|
|
|
44
44
|
* @extends {EventDispatcher}
|
|
45
45
|
* @param {SortableTitlePlugin.Options=} options
|
|
46
46
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
let SortableTitlePlugin = function (options) { // TODO: Extract SortableTitlePlugin to grid extension.
|
|
48
|
+
let _t = this;
|
|
49
49
|
_t._onSectionAdded = _t._onSectionAdded.bind(_t);
|
|
50
50
|
_t._onMouseDown = _t._onMouseDown.bind(_t);
|
|
51
51
|
|
|
@@ -236,17 +236,17 @@ SortableTitlePlugin.prototype._sortingSequenceMap = null;
|
|
|
236
236
|
* @private
|
|
237
237
|
* @const
|
|
238
238
|
*/
|
|
239
|
-
|
|
239
|
+
let CODE_UP = "\u25B2";
|
|
240
240
|
/** @type {string}
|
|
241
241
|
* @private
|
|
242
242
|
* @const
|
|
243
243
|
*/
|
|
244
|
-
|
|
244
|
+
let CODE_DOWN = "\u25BC";
|
|
245
245
|
/** @type {string}
|
|
246
246
|
* @private
|
|
247
247
|
* @const
|
|
248
248
|
*/
|
|
249
|
-
|
|
249
|
+
let CODE_DIAMOND = "\u25CA";
|
|
250
250
|
|
|
251
251
|
/** The name must be readonly and unique among all other plugins
|
|
252
252
|
* @public
|
|
@@ -282,7 +282,7 @@ SortableTitlePlugin.prototype.initialize = function (host, options) {
|
|
|
282
282
|
* @param {!Core} host
|
|
283
283
|
*/
|
|
284
284
|
SortableTitlePlugin.prototype.unload = function (host) {
|
|
285
|
-
|
|
285
|
+
let at = this._hosts.indexOf(host);
|
|
286
286
|
if (at < 0) { return; }
|
|
287
287
|
|
|
288
288
|
this._hosts.splice(at, 1);
|
|
@@ -304,12 +304,12 @@ SortableTitlePlugin.prototype.unload = function (host) {
|
|
|
304
304
|
/** @public
|
|
305
305
|
*/
|
|
306
306
|
SortableTitlePlugin.prototype.afterInit = function () {
|
|
307
|
-
|
|
307
|
+
let t = this;
|
|
308
308
|
|
|
309
309
|
// Set logic to the data source, since the data source not available during the initialization
|
|
310
310
|
t.setSortLogics(t._sortLogic);
|
|
311
311
|
|
|
312
|
-
|
|
312
|
+
let userInput = t._initialSort; // This will be passed from the user when they want to start with initialize sort
|
|
313
313
|
if (userInput != null) {
|
|
314
314
|
if(Array.isArray(userInput)) {
|
|
315
315
|
if(t._maxCount === 1) { // TODO: max count could be part of sortColumns method
|
|
@@ -329,15 +329,15 @@ SortableTitlePlugin.prototype.afterInit = function () {
|
|
|
329
329
|
SortableTitlePlugin.prototype.config = function (options) {
|
|
330
330
|
if (!options) { return; }
|
|
331
331
|
|
|
332
|
-
|
|
332
|
+
let t = this;
|
|
333
333
|
|
|
334
|
-
|
|
334
|
+
let icons = options["icons"];
|
|
335
335
|
if (icons != null) {
|
|
336
336
|
if (icons["sorting"]) {
|
|
337
337
|
SortableTitlePlugin._icons = icons["sorting"];
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
|
|
340
|
+
let themeName = options["themeName"];
|
|
341
341
|
if (!themeName || themeName.indexOf("solar") >= 0) {
|
|
342
342
|
t._solarTheme = true;
|
|
343
343
|
} else {
|
|
@@ -345,7 +345,7 @@ SortableTitlePlugin.prototype.config = function (options) {
|
|
|
345
345
|
}
|
|
346
346
|
t._initialSort = t._initialSortByColumnField(options);
|
|
347
347
|
|
|
348
|
-
|
|
348
|
+
let extOptions = options["sorting"];
|
|
349
349
|
if (!extOptions) {
|
|
350
350
|
return;
|
|
351
351
|
}
|
|
@@ -357,7 +357,7 @@ SortableTitlePlugin.prototype.config = function (options) {
|
|
|
357
357
|
t._userManagedLogic = true;
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
-
|
|
360
|
+
let val = extOptions["multiColumn"] || extOptions["multicolumn"];
|
|
361
361
|
if (val != null) {
|
|
362
362
|
if (val === true) val = -1;
|
|
363
363
|
if (val === false) val = 1;
|
|
@@ -434,7 +434,7 @@ SortableTitlePlugin.prototype.config = function (options) {
|
|
|
434
434
|
|
|
435
435
|
val = extOptions["sortLogic"];
|
|
436
436
|
if (typeof val === "object") {
|
|
437
|
-
for (
|
|
437
|
+
for (let field in val) {
|
|
438
438
|
if (typeof val[field] === "function") {
|
|
439
439
|
t._sortLogic[field] = val[field];
|
|
440
440
|
}
|
|
@@ -447,26 +447,26 @@ SortableTitlePlugin.prototype.config = function (options) {
|
|
|
447
447
|
* @return {!Object}
|
|
448
448
|
*/
|
|
449
449
|
SortableTitlePlugin.prototype.getConfigObject = function (gridOptions) {
|
|
450
|
-
|
|
450
|
+
let obj = gridOptions || {};
|
|
451
451
|
|
|
452
|
-
|
|
452
|
+
let columns = obj["columns"];
|
|
453
453
|
if (!columns) {
|
|
454
454
|
columns = obj["columns"] = [];
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
|
|
457
|
+
let host = this._hosts[0];
|
|
458
458
|
|
|
459
459
|
if (!host) return obj;
|
|
460
460
|
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
let sortedColumns = this.getSortedColumns();
|
|
462
|
+
let col, i, len;
|
|
463
463
|
// Multiple column sorting cannot retain the sort order in the column option.
|
|
464
464
|
if(this._maxCount === 1 && sortedColumns != null) {
|
|
465
465
|
// assign sorting state to each columns
|
|
466
466
|
len = sortedColumns.length;
|
|
467
467
|
for (i = 0; i < len; i++) {
|
|
468
|
-
|
|
469
|
-
|
|
468
|
+
let sortedColumn = sortedColumns[i];
|
|
469
|
+
let colIndex = sortedColumn["colIndex"];
|
|
470
470
|
col = columns[colIndex];
|
|
471
471
|
if (!col) {
|
|
472
472
|
col = columns[colIndex] = {};
|
|
@@ -476,7 +476,7 @@ SortableTitlePlugin.prototype.getConfigObject = function (gridOptions) {
|
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
len = host.getColumnCount();
|
|
479
|
-
|
|
479
|
+
let opt, field;
|
|
480
480
|
for(i = 0; i < len; ++i) {
|
|
481
481
|
col = columns[i];
|
|
482
482
|
if (!col) {
|
|
@@ -509,12 +509,12 @@ SortableTitlePlugin.prototype.getConfigObject = function (gridOptions) {
|
|
|
509
509
|
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
-
|
|
512
|
+
let extOptions = obj["sorting"];
|
|
513
513
|
if(!extOptions) {
|
|
514
514
|
extOptions = obj["sorting"] = {};
|
|
515
515
|
}
|
|
516
516
|
|
|
517
|
-
|
|
517
|
+
let val = sortedColumns;
|
|
518
518
|
if(val != null) {
|
|
519
519
|
extOptions["initialSort"] = val;
|
|
520
520
|
}
|
|
@@ -545,8 +545,8 @@ SortableTitlePlugin.prototype.getConfigObject = function (gridOptions) {
|
|
|
545
545
|
extOptions["disabled"] = true;
|
|
546
546
|
}
|
|
547
547
|
|
|
548
|
-
|
|
549
|
-
|
|
548
|
+
let sortingSeq = this._sortingSequence;
|
|
549
|
+
let notDefaultSeq = true;
|
|
550
550
|
if (sortingSeq.length === 2) {
|
|
551
551
|
if (sortingSeq[0] === "a" && sortingSeq[1] === "d") { // Sorting Sequence is not the default one
|
|
552
552
|
notDefaultSeq = false;
|
|
@@ -574,22 +574,22 @@ SortableTitlePlugin.prototype.getColumnMenu = function (colIndex, config) {
|
|
|
574
574
|
config = {};
|
|
575
575
|
}
|
|
576
576
|
|
|
577
|
-
|
|
577
|
+
let menus = config["menus"];
|
|
578
578
|
if (!menus) {
|
|
579
579
|
menus = config["menus"] = [];
|
|
580
580
|
}
|
|
581
581
|
|
|
582
|
-
|
|
582
|
+
let menu = menus[0];
|
|
583
583
|
if (!menu) {
|
|
584
584
|
menu = menus[0] = {
|
|
585
585
|
"menuItems": []
|
|
586
586
|
};
|
|
587
587
|
}
|
|
588
588
|
|
|
589
|
-
|
|
589
|
+
let order = this.getSortOrder(colIndex);
|
|
590
590
|
|
|
591
591
|
// Menu items for this extension
|
|
592
|
-
|
|
592
|
+
let extMenuItem = {
|
|
593
593
|
"indexScore": 100,
|
|
594
594
|
"label": "Sort Column",
|
|
595
595
|
"icon": "sort-a-to-z",
|
|
@@ -639,13 +639,13 @@ SortableTitlePlugin.prototype.getColumnMenu = function (colIndex, config) {
|
|
|
639
639
|
* @param {Object} e
|
|
640
640
|
*/
|
|
641
641
|
SortableTitlePlugin.prototype._onItemSortingClicked = function (e) {
|
|
642
|
-
|
|
643
|
-
|
|
642
|
+
let host = this._hosts[0];
|
|
643
|
+
let columnMenuExt = host["getPlugin"]("ColumnMenuPlugin");
|
|
644
644
|
columnMenuExt["hide"]();
|
|
645
645
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
646
|
+
let value = e["currentTarget"]["value"];
|
|
647
|
+
let colIndex = value["colIndex"];
|
|
648
|
+
let order = value["sortOrder"];
|
|
649
649
|
this.sortColumn(colIndex, order);
|
|
650
650
|
};
|
|
651
651
|
|
|
@@ -661,10 +661,10 @@ SortableTitlePlugin.prototype.getIcons = function () {
|
|
|
661
661
|
*/
|
|
662
662
|
SortableTitlePlugin.prototype.setSortLogics = function (sortLogic) { // TODO: This should be deprecated
|
|
663
663
|
if (sortLogic != null) {
|
|
664
|
-
|
|
664
|
+
let host = this._hosts[0];
|
|
665
665
|
if (host) {
|
|
666
|
-
|
|
667
|
-
for (
|
|
666
|
+
let ds = host.getDataSource();
|
|
667
|
+
for (let field in sortLogic) {
|
|
668
668
|
this._setSortLogic(ds, field, sortLogic[field]);
|
|
669
669
|
}
|
|
670
670
|
}
|
|
@@ -677,9 +677,9 @@ SortableTitlePlugin.prototype.setSortLogics = function (sortLogic) { // TODO: Th
|
|
|
677
677
|
*/
|
|
678
678
|
SortableTitlePlugin.prototype.setSortLogic = function (field, func) { // TODO: This should be deprecated
|
|
679
679
|
if (typeof field === "string") {
|
|
680
|
-
|
|
680
|
+
let host = this._hosts[0];
|
|
681
681
|
if (host) {
|
|
682
|
-
|
|
682
|
+
let ds = host.getDataSource();
|
|
683
683
|
this._setSortLogic(ds, field, func);
|
|
684
684
|
}
|
|
685
685
|
}
|
|
@@ -705,9 +705,9 @@ SortableTitlePlugin.prototype._setSortLogic = function (ds, field, func) { // TO
|
|
|
705
705
|
* @return {string} "a" for ascending, "d" for descending, and "n" for no sorting
|
|
706
706
|
*/
|
|
707
707
|
SortableTitlePlugin.prototype.getSortOrder = function (colIndex) {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
708
|
+
let priority = (colIndex != null) ? this.getSortPriority(colIndex) : 0;
|
|
709
|
+
let state = this._sortStates[priority];
|
|
710
|
+
let sortOrder = state ? state["sortOrder"] : "";
|
|
711
711
|
return sortOrder || "n";
|
|
712
712
|
};
|
|
713
713
|
/** Return the first (highest priority) sorted column's index
|
|
@@ -725,12 +725,12 @@ SortableTitlePlugin.prototype.getSortedColumnIndex = function (priority) {
|
|
|
725
725
|
* @return {number}
|
|
726
726
|
*/
|
|
727
727
|
SortableTitlePlugin.prototype.getSortPriority = function (colIndex, colRef) {
|
|
728
|
-
|
|
728
|
+
let host = this._hosts[0];
|
|
729
729
|
if(host) {
|
|
730
|
-
|
|
731
|
-
|
|
730
|
+
let i;
|
|
731
|
+
let len = this._sortStates.length;
|
|
732
732
|
if(colIndex >= 0) {
|
|
733
|
-
|
|
733
|
+
let colId = host.getColumnId(colIndex);
|
|
734
734
|
if(colId) {
|
|
735
735
|
for(i = 0; i < len; ++i) {
|
|
736
736
|
if(this._sortStates[i]["colId"] === colId) {
|
|
@@ -740,7 +740,7 @@ SortableTitlePlugin.prototype.getSortPriority = function (colIndex, colRef) {
|
|
|
740
740
|
}
|
|
741
741
|
} else if(colRef) {
|
|
742
742
|
for(i = 0; i < len; ++i) {
|
|
743
|
-
|
|
743
|
+
let sortState = this._sortStates[i];
|
|
744
744
|
if(sortState["colId"] === colRef) {
|
|
745
745
|
return i;
|
|
746
746
|
}
|
|
@@ -763,15 +763,15 @@ SortableTitlePlugin.prototype.isColumnSorted = function (colIndex) {
|
|
|
763
763
|
* @return {Array.<Object>} Array of objects with colIndex, colId, field, and sortOrder properties
|
|
764
764
|
*/
|
|
765
765
|
SortableTitlePlugin.prototype.getSortedColumns = function () {
|
|
766
|
-
|
|
766
|
+
let len = this._sortStates.length;
|
|
767
767
|
if (len <= 0) { return null; }
|
|
768
768
|
|
|
769
|
-
|
|
770
|
-
for (
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
769
|
+
let arr = new Array(len);
|
|
770
|
+
for (let i = 0; i < len; ++i) {
|
|
771
|
+
let colIndex = this.getSortedColumnIndex(i);
|
|
772
|
+
let state = this._sortStates[i];
|
|
773
|
+
let retObj = {};
|
|
774
|
+
let colId = "";
|
|
775
775
|
if(colIndex >= 0) {
|
|
776
776
|
retObj["colIndex"] = colIndex;
|
|
777
777
|
colId = this._getColumnId(colIndex);
|
|
@@ -779,7 +779,7 @@ SortableTitlePlugin.prototype.getSortedColumns = function () {
|
|
|
779
779
|
if(colId) {
|
|
780
780
|
retObj["colId"] = colId;
|
|
781
781
|
}
|
|
782
|
-
|
|
782
|
+
let field = state["field"] || "";
|
|
783
783
|
if(field) {
|
|
784
784
|
retObj["field"] = field;
|
|
785
785
|
}
|
|
@@ -815,9 +815,9 @@ SortableTitlePlugin.prototype.sortColumn = function (colRef, sortOrder, opt_arg)
|
|
|
815
815
|
*/
|
|
816
816
|
SortableTitlePlugin.prototype.sortColumns = function (sortOptions, opt_arg) {
|
|
817
817
|
if (Array.isArray(sortOptions)) {
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
for (
|
|
818
|
+
let len = sortOptions.length;
|
|
819
|
+
let states = new Array(len);
|
|
820
|
+
for (let i = 0; i < len; i++) {
|
|
821
821
|
states[i] = this._prepareSorting(sortOptions[i]);
|
|
822
822
|
}
|
|
823
823
|
this._sortColumn(states, opt_arg);
|
|
@@ -870,7 +870,7 @@ SortableTitlePlugin.prototype.getSortingStates = function () {
|
|
|
870
870
|
*/
|
|
871
871
|
SortableTitlePlugin.prototype.updateSortSymbols = function () {
|
|
872
872
|
if(!this._disabled) {
|
|
873
|
-
for (
|
|
873
|
+
for (let i = this._hosts.length; --i >= 0;) {
|
|
874
874
|
this._updateSortableIndicator(i);
|
|
875
875
|
}
|
|
876
876
|
}
|
|
@@ -881,11 +881,11 @@ SortableTitlePlugin.prototype.updateSortSymbols = function () {
|
|
|
881
881
|
* @return {!Array.<string>}
|
|
882
882
|
*/
|
|
883
883
|
SortableTitlePlugin.prototype.getDataColumnMap = function () {
|
|
884
|
-
|
|
885
|
-
|
|
884
|
+
let host = this._hosts[0];
|
|
885
|
+
let dataMap = [];
|
|
886
886
|
if (host) {
|
|
887
|
-
|
|
888
|
-
for (
|
|
887
|
+
let colCount = host.getColumnCount();
|
|
888
|
+
for (let i = 0; i < colCount; ++i) {
|
|
889
889
|
dataMap[i] = this.getColumnSortingField(i);
|
|
890
890
|
}
|
|
891
891
|
}
|
|
@@ -900,7 +900,7 @@ SortableTitlePlugin.prototype.getDataColumnNames = SortableTitlePlugin.prototype
|
|
|
900
900
|
SortableTitlePlugin.prototype.setDataColumnMap = function (dataMap) { // TODO: This should be deprecated
|
|
901
901
|
// This should work just like "sortBy"
|
|
902
902
|
if (Array.isArray(dataMap)) {
|
|
903
|
-
for (
|
|
903
|
+
for (let i = dataMap.length; --i >= 0;) {
|
|
904
904
|
this.setColumnSortingField(i, dataMap[i]);
|
|
905
905
|
}
|
|
906
906
|
}
|
|
@@ -912,12 +912,12 @@ SortableTitlePlugin.prototype.setDataColumnNames = SortableTitlePlugin.prototype
|
|
|
912
912
|
* @return {string} field A field used for sorting
|
|
913
913
|
*/
|
|
914
914
|
SortableTitlePlugin.prototype.getColumnSortingField = function (colIndex) {
|
|
915
|
-
|
|
915
|
+
let sortOptions = this._getSortOptions(colIndex);
|
|
916
916
|
// options["field"] is already consolidated from field, sortBy, and sortable properties.
|
|
917
|
-
|
|
917
|
+
let field = (sortOptions) ? sortOptions["field"] : null;
|
|
918
918
|
|
|
919
919
|
if (field == null && !this._rowDefMode) { // Old CompositeGrid may store sorting field in DataColumnName
|
|
920
|
-
|
|
920
|
+
let host = this._hosts[0];
|
|
921
921
|
if (host) {
|
|
922
922
|
field = host.getColumnField(colIndex);
|
|
923
923
|
if(!field) {
|
|
@@ -940,7 +940,7 @@ SortableTitlePlugin.prototype.getColumnSortingField = function (colIndex) {
|
|
|
940
940
|
*/
|
|
941
941
|
SortableTitlePlugin.prototype.setColumnSortingField = function (colIndex, field, sortLogic, rowSorting) {
|
|
942
942
|
if (typeof colIndex == "number" && field != null) {
|
|
943
|
-
|
|
943
|
+
let options = this._newSortOptions(colIndex);
|
|
944
944
|
if (!field) {
|
|
945
945
|
field = "";
|
|
946
946
|
}
|
|
@@ -962,7 +962,7 @@ SortableTitlePlugin.prototype.setColumnSortingField = function (colIndex, field,
|
|
|
962
962
|
* @param {Object} sortState
|
|
963
963
|
* @returns {string}
|
|
964
964
|
*/
|
|
965
|
-
|
|
965
|
+
let _toField = function(sortState) {
|
|
966
966
|
return sortState["field"] || "";
|
|
967
967
|
};
|
|
968
968
|
/** Return array of the fields from the currently sorted columns
|
|
@@ -989,18 +989,18 @@ SortableTitlePlugin.prototype.setFirstSortOrder = function (colIdentifier, sortO
|
|
|
989
989
|
sortOrder = "a"; // There is no "none" as the first sorting order
|
|
990
990
|
}
|
|
991
991
|
|
|
992
|
-
|
|
992
|
+
let fields = null;
|
|
993
993
|
if (Array.isArray(colIdentifier)) {
|
|
994
994
|
fields = colIdentifier;
|
|
995
995
|
} else {
|
|
996
996
|
fields = [/** @type{string|number} */(colIdentifier)];
|
|
997
997
|
}
|
|
998
998
|
|
|
999
|
-
|
|
1000
|
-
for (
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
999
|
+
let len = fields.length;
|
|
1000
|
+
for (let i = 0; i < len; ++i) {
|
|
1001
|
+
let field = fields[i];
|
|
1002
|
+
let sortingSeq = this.getSortingSequence(field).slice();
|
|
1003
|
+
let index = sortingSeq.indexOf(sortOrder);
|
|
1004
1004
|
if (index >= 0) {
|
|
1005
1005
|
sortingSeq.splice(index, 1);
|
|
1006
1006
|
}
|
|
@@ -1016,7 +1016,7 @@ SortableTitlePlugin.prototype.setFirstSortOrder = function (colIdentifier, sortO
|
|
|
1016
1016
|
* @see {@link SortableTitlePlugin#setSortingSequence}
|
|
1017
1017
|
*/
|
|
1018
1018
|
SortableTitlePlugin.prototype.disableTwoStateSorting = function (disabled) {
|
|
1019
|
-
|
|
1019
|
+
let at = this._sortingSequence.indexOf("n");
|
|
1020
1020
|
if(disabled === false) { // two-state sorting
|
|
1021
1021
|
if(at >= 0) {
|
|
1022
1022
|
this._sortingSequence.splice(at, 1);
|
|
@@ -1032,10 +1032,10 @@ SortableTitlePlugin.prototype.disableTwoStateSorting = function (disabled) {
|
|
|
1032
1032
|
* @param {boolean=} bool=true, if set to false it will be unfreeze indicator
|
|
1033
1033
|
*/
|
|
1034
1034
|
SortableTitlePlugin.prototype.freezeIndicator = function (bool) {
|
|
1035
|
-
|
|
1035
|
+
let prevState = this._frozenIndicator;
|
|
1036
1036
|
this._frozenIndicator = bool !== false;
|
|
1037
1037
|
if(prevState && !this._frozenIndicator) { // from frozen to unfrozen, update the ui
|
|
1038
|
-
for (
|
|
1038
|
+
for (let i = this._hosts.length; --i >= 0;) {
|
|
1039
1039
|
this._updateSortableIndicator(i);
|
|
1040
1040
|
}
|
|
1041
1041
|
}
|
|
@@ -1080,8 +1080,8 @@ SortableTitlePlugin.prototype.disableColumnSorting = function (columns, disabled
|
|
|
1080
1080
|
if (typeof columns === "number") {
|
|
1081
1081
|
this._disableColumnSorting(columns, disabled);
|
|
1082
1082
|
} else if (Array.isArray(columns)) {
|
|
1083
|
-
|
|
1084
|
-
for (
|
|
1083
|
+
let len = columns.length;
|
|
1084
|
+
for (let i = 0; i < len; ++i) {
|
|
1085
1085
|
this._disableColumnSorting(columns[i] || 0, disabled);
|
|
1086
1086
|
}
|
|
1087
1087
|
}
|
|
@@ -1091,7 +1091,7 @@ SortableTitlePlugin.prototype.disableColumnSorting = function (columns, disabled
|
|
|
1091
1091
|
* @param {boolean} disabled
|
|
1092
1092
|
*/
|
|
1093
1093
|
SortableTitlePlugin.prototype._disableColumnSorting = function (colIndex, disabled) {
|
|
1094
|
-
|
|
1094
|
+
let sortOptions = this._newSortOptions(colIndex);
|
|
1095
1095
|
if (sortOptions["disabled"] !== disabled) {
|
|
1096
1096
|
sortOptions["disabled"] = disabled;
|
|
1097
1097
|
// TODO: Remove existing sort
|
|
@@ -1111,11 +1111,11 @@ SortableTitlePlugin.prototype.setClickDelayInterval = function (opt_ms) {
|
|
|
1111
1111
|
* @returns {Object}
|
|
1112
1112
|
*/
|
|
1113
1113
|
SortableTitlePlugin.prototype._initialSortByColumnField = function (options) {
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
for (
|
|
1117
|
-
|
|
1118
|
-
|
|
1114
|
+
let columns = options["columns"];
|
|
1115
|
+
let colCount = columns ? columns.length : 0;
|
|
1116
|
+
for (let i = 0; i < colCount; i++) {
|
|
1117
|
+
let column = columns[i];
|
|
1118
|
+
let sortOrder = column["defaultSort"]; // composite and rt grid option for default sort order
|
|
1119
1119
|
if (sortOrder) {
|
|
1120
1120
|
// TODO: Support multi-column sorting
|
|
1121
1121
|
return {
|
|
@@ -1133,7 +1133,7 @@ SortableTitlePlugin.prototype._initialSortByColumnField = function (options) {
|
|
|
1133
1133
|
SortableTitlePlugin.prototype._onSectionAdded = function (e) {
|
|
1134
1134
|
if (e["sectionType"] !== "title") { return; }
|
|
1135
1135
|
|
|
1136
|
-
|
|
1136
|
+
let section = /** @type{ILayoutGrid} */(e["section"]);
|
|
1137
1137
|
if (section.getIndex() !== 0) return; // only topmost header can click
|
|
1138
1138
|
section.listen("mousedown", this._onMouseDown);
|
|
1139
1139
|
section.listen("click", this._onClickTitle.bind(this, e["sender"]), 0); // Sorting has higher priority
|
|
@@ -1158,12 +1158,12 @@ SortableTitlePlugin.prototype._canClickToSort = function (hitObj) {
|
|
|
1158
1158
|
return false;
|
|
1159
1159
|
}
|
|
1160
1160
|
|
|
1161
|
-
|
|
1161
|
+
let grid = hitObj["grid"];
|
|
1162
1162
|
if (!grid || !grid.getElement()) { // The given grid has been disposed
|
|
1163
1163
|
return false;
|
|
1164
1164
|
}
|
|
1165
1165
|
|
|
1166
|
-
|
|
1166
|
+
let cep = this._getPlugin("CellEditingPlugin");
|
|
1167
1167
|
if (cep && cep["isEditing"]()) { // Current cell is being edited, so skip the sort
|
|
1168
1168
|
return false;
|
|
1169
1169
|
}
|
|
@@ -1173,9 +1173,9 @@ SortableTitlePlugin.prototype._canClickToSort = function (hitObj) {
|
|
|
1173
1173
|
return false;
|
|
1174
1174
|
}
|
|
1175
1175
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1176
|
+
let colIndex = hitObj["colIndex"];
|
|
1177
|
+
let section = hitObj["section"];
|
|
1178
|
+
let rowIndex = hitObj["rowIndex"];
|
|
1179
1179
|
|
|
1180
1180
|
if (!this._isCellSortable(section, colIndex, rowIndex)) {
|
|
1181
1181
|
return false;
|
|
@@ -1194,17 +1194,17 @@ SortableTitlePlugin.prototype._proceedSorting = function (hitObj) {
|
|
|
1194
1194
|
this._clickTimer = 0;
|
|
1195
1195
|
|
|
1196
1196
|
if (this._canClickToSort(hitObj)) {
|
|
1197
|
-
|
|
1197
|
+
let colIndex = hitObj["colIndex"];
|
|
1198
1198
|
// _proceedSorting() method is always produced by user clicking at the header // Thus, this operation is guaranteed to be a user action
|
|
1199
1199
|
this.sortColumn(colIndex, null, { "isUserAction": true });
|
|
1200
1200
|
|
|
1201
|
-
|
|
1201
|
+
let grid = hitObj["grid"];
|
|
1202
1202
|
if(grid && grid["focus"]) {
|
|
1203
1203
|
grid["focus"]();
|
|
1204
1204
|
}
|
|
1205
1205
|
|
|
1206
1206
|
if (this._hasListener("clicked")) {
|
|
1207
|
-
|
|
1207
|
+
let ce = {};
|
|
1208
1208
|
ce["colIndex"] = colIndex;
|
|
1209
1209
|
ce["sortOrder"] = this.getSortOrder(colIndex);
|
|
1210
1210
|
ce["dataColumnName"] = this.getColumnSortingField(colIndex); // This should be deprecated
|
|
@@ -1226,7 +1226,7 @@ SortableTitlePlugin.prototype._onMouseDown = function (e) {
|
|
|
1226
1226
|
* @return {*|null}
|
|
1227
1227
|
*/
|
|
1228
1228
|
SortableTitlePlugin.prototype._getPlugin = function(pluginName) {
|
|
1229
|
-
|
|
1229
|
+
let host = this._hosts[0];
|
|
1230
1230
|
return (host) ? host.getPlugin(pluginName) : null;
|
|
1231
1231
|
};
|
|
1232
1232
|
/** @private
|
|
@@ -1252,14 +1252,14 @@ SortableTitlePlugin.prototype._onClickTitle = function (grid, e) {
|
|
|
1252
1252
|
return;
|
|
1253
1253
|
}
|
|
1254
1254
|
|
|
1255
|
-
|
|
1255
|
+
let hitObj = grid.getRelativePosition(e);
|
|
1256
1256
|
if (!hitObj["hit"]) { // Click across multiple elements (dragging)
|
|
1257
1257
|
return;
|
|
1258
1258
|
}
|
|
1259
1259
|
|
|
1260
|
-
|
|
1260
|
+
let csp = this._getPlugin("ColumnSelectionPlugin");
|
|
1261
1261
|
if (csp && csp["isEnabled"]()) {
|
|
1262
|
-
|
|
1262
|
+
let colIndex = hitObj["colIndex"];
|
|
1263
1263
|
if (!csp["isSelectedColumn"](colIndex)) { // Sort only if the column is selected
|
|
1264
1264
|
return;
|
|
1265
1265
|
}
|
|
@@ -1287,8 +1287,8 @@ SortableTitlePlugin.prototype._onClickTitle = function (grid, e) {
|
|
|
1287
1287
|
SortableTitlePlugin.prototype._popSortState = function (toIndex, opt_arg) {
|
|
1288
1288
|
if (toIndex < 0 || this._sortStates.length <= toIndex) { return false; }
|
|
1289
1289
|
|
|
1290
|
-
|
|
1291
|
-
for (
|
|
1290
|
+
let dirty = false;
|
|
1291
|
+
for (let i = this._sortStates.length; --i >= toIndex;) {
|
|
1292
1292
|
this._clearSortSymbols(this._sortStates[i]);
|
|
1293
1293
|
dirty = true;
|
|
1294
1294
|
}
|
|
@@ -1345,7 +1345,7 @@ SortableTitlePlugin.prototype.setSortingSequence = function (sequence, colRef) {
|
|
|
1345
1345
|
return;
|
|
1346
1346
|
}
|
|
1347
1347
|
|
|
1348
|
-
|
|
1348
|
+
let field;
|
|
1349
1349
|
if (colRef != null) {
|
|
1350
1350
|
if (typeof colRef === "string") {
|
|
1351
1351
|
field = colRef;
|
|
@@ -1356,7 +1356,7 @@ SortableTitlePlugin.prototype.setSortingSequence = function (sequence, colRef) {
|
|
|
1356
1356
|
|
|
1357
1357
|
if (sequence) {
|
|
1358
1358
|
// Ensure that user sequence has only valid sort order
|
|
1359
|
-
|
|
1359
|
+
let sortingSequence = sequence.map(SortableTitlePlugin._toSortOrder);
|
|
1360
1360
|
if (field) {
|
|
1361
1361
|
if (!this._sortingSequenceMap) {
|
|
1362
1362
|
this._sortingSequenceMap = {};
|
|
@@ -1386,19 +1386,19 @@ SortableTitlePlugin.prototype.clearAllColumnSortingSequences = function () {
|
|
|
1386
1386
|
* @param {Function} comparer Compare function
|
|
1387
1387
|
*/
|
|
1388
1388
|
SortableTitlePlugin.prototype.sortSeparators = function (comparer) {
|
|
1389
|
-
|
|
1390
|
-
|
|
1389
|
+
let host = this._hosts[0];
|
|
1390
|
+
let dv = host.getDataSource();
|
|
1391
1391
|
if(comparer){
|
|
1392
1392
|
dv.sortSeparators(comparer);
|
|
1393
1393
|
} else {
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
for(
|
|
1400
|
-
|
|
1401
|
-
|
|
1394
|
+
let sortLogics = dv.getSortingLogics();
|
|
1395
|
+
let sortOrders = [];
|
|
1396
|
+
let sortFields = [];
|
|
1397
|
+
let sortStateCount = this._sortStates.length;
|
|
1398
|
+
let rowDefField = SortableTitlePlugin._toRowDefField();
|
|
1399
|
+
for(let i = 0; i < sortStateCount; i++){
|
|
1400
|
+
let sortState = this._sortStates[i];
|
|
1401
|
+
let field = this._rowDefMode ? rowDefField : sortState["field"];
|
|
1402
1402
|
sortOrders.push(sortState["sortOrder"]);
|
|
1403
1403
|
sortFields.push(field);
|
|
1404
1404
|
}
|
|
@@ -1416,13 +1416,13 @@ SortableTitlePlugin.prototype._prepareSorting = function (sortingDef, sortOrder)
|
|
|
1416
1416
|
if (!this._maxCount) {
|
|
1417
1417
|
return null;
|
|
1418
1418
|
}
|
|
1419
|
-
|
|
1419
|
+
let host = this._hosts[0];
|
|
1420
1420
|
if(!host) {
|
|
1421
1421
|
return null;
|
|
1422
1422
|
}
|
|
1423
1423
|
|
|
1424
|
-
|
|
1425
|
-
|
|
1424
|
+
let colIndex = -1;
|
|
1425
|
+
let colRef = "";
|
|
1426
1426
|
if(typeof sortingDef === "number") {
|
|
1427
1427
|
colIndex = sortingDef;
|
|
1428
1428
|
} else if(typeof sortingDef === "string") { // This would be either column id or field
|
|
@@ -1440,11 +1440,11 @@ SortableTitlePlugin.prototype._prepareSorting = function (sortingDef, sortOrder)
|
|
|
1440
1440
|
}
|
|
1441
1441
|
}
|
|
1442
1442
|
|
|
1443
|
-
|
|
1444
|
-
|
|
1443
|
+
let field = "";
|
|
1444
|
+
let sortLogic = null;
|
|
1445
1445
|
if(colIndex >= 0) {
|
|
1446
1446
|
field = this.getColumnSortingField(colIndex);
|
|
1447
|
-
|
|
1447
|
+
let sortOptions = this._getSortOptions(colIndex);
|
|
1448
1448
|
if(sortOptions) {
|
|
1449
1449
|
sortLogic = sortOptions["sortLogic"];
|
|
1450
1450
|
}
|
|
@@ -1452,16 +1452,16 @@ SortableTitlePlugin.prototype._prepareSorting = function (sortingDef, sortOrder)
|
|
|
1452
1452
|
field = colRef; // Assume that colRef is a field and not a column id
|
|
1453
1453
|
}
|
|
1454
1454
|
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1455
|
+
let priority = this.getSortPriority(colIndex, field);
|
|
1456
|
+
let curState = (priority >= 0) ? this._sortStates[priority] : null;
|
|
1457
|
+
let curOrder = curState ? curState["sortOrder"] : "n";
|
|
1458
1458
|
|
|
1459
1459
|
// Getting next sort order
|
|
1460
|
-
|
|
1460
|
+
let nextOrder = "n";
|
|
1461
1461
|
if (sortOrder == null) { // Auto order switch
|
|
1462
|
-
|
|
1462
|
+
let sortingSequence = this.getSortingSequence(field);
|
|
1463
1463
|
|
|
1464
|
-
|
|
1464
|
+
let sequenceIndex = sortingSequence.indexOf(curOrder);
|
|
1465
1465
|
if (sequenceIndex < 0) {
|
|
1466
1466
|
sequenceIndex = 0;
|
|
1467
1467
|
} else {
|
|
@@ -1488,7 +1488,7 @@ SortableTitlePlugin.prototype._prepareSorting = function (sortingDef, sortOrder)
|
|
|
1488
1488
|
}
|
|
1489
1489
|
if (!curState) {
|
|
1490
1490
|
curState = {};
|
|
1491
|
-
|
|
1491
|
+
let colId = host.getColumnId(colIndex);
|
|
1492
1492
|
if(colId) {
|
|
1493
1493
|
curState["colId"] = colId;
|
|
1494
1494
|
}
|
|
@@ -1509,10 +1509,10 @@ SortableTitlePlugin.prototype._prepareSorting = function (sortingDef, sortOrder)
|
|
|
1509
1509
|
curState["sortOrder"] = nextOrder;
|
|
1510
1510
|
}
|
|
1511
1511
|
|
|
1512
|
-
|
|
1512
|
+
let clearedSortColIndexes = [];
|
|
1513
1513
|
if (this._maxCount > 0) {
|
|
1514
1514
|
while (this._sortStates.length > this._maxCount) { // Shift excess
|
|
1515
|
-
|
|
1515
|
+
let index = this._clearSortSymbols(this._sortStates.shift());
|
|
1516
1516
|
if (index !== null) {
|
|
1517
1517
|
clearedSortColIndexes.push(index);
|
|
1518
1518
|
}
|
|
@@ -1542,11 +1542,11 @@ SortableTitlePlugin.prototype._sortColumn = function (states, opt_arg) {
|
|
|
1542
1542
|
this._sortDataView(opt_arg); // Update Data
|
|
1543
1543
|
this.updateSortSymbols(); // Update Display
|
|
1544
1544
|
|
|
1545
|
-
|
|
1545
|
+
let evtArg = null;
|
|
1546
1546
|
if(Array.isArray(states)) {
|
|
1547
|
-
|
|
1548
|
-
for(
|
|
1549
|
-
|
|
1547
|
+
let len = states.length;
|
|
1548
|
+
for(let i = 0; i < len; ++i) {
|
|
1549
|
+
let state = states[i];
|
|
1550
1550
|
if(state) {
|
|
1551
1551
|
if(evtArg) {
|
|
1552
1552
|
if(!evtArg["colIndices"]) {
|
|
@@ -1576,13 +1576,13 @@ SortableTitlePlugin.prototype._sortColumn = function (states, opt_arg) {
|
|
|
1576
1576
|
* @param {Object} e
|
|
1577
1577
|
*/
|
|
1578
1578
|
SortableTitlePlugin.prototype._onColumnAdded = function (e) {
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1579
|
+
let t = this;
|
|
1580
|
+
let colIndex = e["colIndex"];
|
|
1581
|
+
let column = e["context"] || {};
|
|
1582
1582
|
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1583
|
+
let sortable = !!t._sortableColumns;
|
|
1584
|
+
let field = column["field"];
|
|
1585
|
+
let sortBy = column["sortBy"];
|
|
1586
1586
|
|
|
1587
1587
|
if (sortBy != null) { // composite grid option
|
|
1588
1588
|
sortable = !!sortBy;
|
|
@@ -1592,7 +1592,7 @@ SortableTitlePlugin.prototype._onColumnAdded = function (e) {
|
|
|
1592
1592
|
sortable = !!column["sortable"];
|
|
1593
1593
|
}
|
|
1594
1594
|
|
|
1595
|
-
|
|
1595
|
+
let sortLogic = column["sortLogic"] || column["sortingLogic"] || column["sorter"]; // Originally, rt grid support option for sortLogic by column
|
|
1596
1596
|
if(!sortLogic) {
|
|
1597
1597
|
sortLogic = t._sortLogic[field];
|
|
1598
1598
|
}
|
|
@@ -1600,7 +1600,7 @@ SortableTitlePlugin.prototype._onColumnAdded = function (e) {
|
|
|
1600
1600
|
sortLogic = null;
|
|
1601
1601
|
}
|
|
1602
1602
|
|
|
1603
|
-
|
|
1603
|
+
let sortingSequence = column["sortingSequence"];
|
|
1604
1604
|
if (sortingSequence != null && field) { // Make sure that column config does not affect grid level config
|
|
1605
1605
|
t.setSortingSequence(sortingSequence, field);
|
|
1606
1606
|
}
|
|
@@ -1611,7 +1611,7 @@ SortableTitlePlugin.prototype._onColumnAdded = function (e) {
|
|
|
1611
1611
|
t.disableColumnSorting(colIndex, true);
|
|
1612
1612
|
}
|
|
1613
1613
|
|
|
1614
|
-
|
|
1614
|
+
let sortOrder = column["sortOrder"] || column["sort"];
|
|
1615
1615
|
if(sortOrder != null) {
|
|
1616
1616
|
sortOrder = SortableTitlePlugin._toSortOrder(sortOrder); // Invalid input will return "n"
|
|
1617
1617
|
if(sortOrder !== "n") {
|
|
@@ -1627,17 +1627,17 @@ SortableTitlePlugin.prototype._onColumnAdded = function (e) {
|
|
|
1627
1627
|
* @fires SortableTitlePlugin#columnSorted
|
|
1628
1628
|
*/
|
|
1629
1629
|
SortableTitlePlugin.prototype._onColumnRemoved = function (e) {
|
|
1630
|
-
|
|
1630
|
+
let sortCount = this._sortStates.length;
|
|
1631
1631
|
if (!sortCount) {
|
|
1632
1632
|
return;
|
|
1633
1633
|
}
|
|
1634
|
-
|
|
1634
|
+
let colId = e["colId"];
|
|
1635
1635
|
if (!colId) {
|
|
1636
1636
|
return;
|
|
1637
1637
|
}
|
|
1638
1638
|
// WARNING: columnRemoved event could be fired repeatedly. Sorting could be triggered multiple times
|
|
1639
|
-
for(
|
|
1640
|
-
|
|
1639
|
+
for(let i = 0; i < sortCount; ++i) {
|
|
1640
|
+
let sortState = this._sortStates[i];
|
|
1641
1641
|
if (sortState["colId"] === colId) {
|
|
1642
1642
|
this._sortStates.splice(i, 1);
|
|
1643
1643
|
this._clearSortSymbols(sortState);
|
|
@@ -1664,17 +1664,17 @@ SortableTitlePlugin.prototype._sortDataView = function (opt_action) {
|
|
|
1664
1664
|
|
|
1665
1665
|
if (!this._dataSorting) { return; }
|
|
1666
1666
|
|
|
1667
|
-
|
|
1667
|
+
let sortCount = this._sortStates.length;
|
|
1668
1668
|
if(this._userManagedLogic && sortCount > 1) { // The logic is managed by the user. There is no point in using multi-column sorting
|
|
1669
1669
|
sortCount = 1;
|
|
1670
1670
|
}
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1671
|
+
let orders = null;
|
|
1672
|
+
let sortLogics = null;
|
|
1673
|
+
let c_ref = null;
|
|
1674
1674
|
if (sortCount) {
|
|
1675
1675
|
orders = new Array(sortCount);
|
|
1676
1676
|
sortLogics = new Array(sortCount);
|
|
1677
|
-
for (
|
|
1677
|
+
for (let i = 0; i < sortCount; ++i) {
|
|
1678
1678
|
orders[i] = this._sortStates[i]["sortOrder"];
|
|
1679
1679
|
sortLogics[i] = this._sortStates[i]["sortLogic"]; // sortLogic can be null
|
|
1680
1680
|
}
|
|
@@ -1689,12 +1689,12 @@ SortableTitlePlugin.prototype._sortDataView = function (opt_action) {
|
|
|
1689
1689
|
}
|
|
1690
1690
|
|
|
1691
1691
|
// Perform sorting even if there is no sort state
|
|
1692
|
-
for (
|
|
1693
|
-
|
|
1692
|
+
for (let j = this._hosts.length; --j >= 0;) {
|
|
1693
|
+
let host = this._hosts[j];
|
|
1694
1694
|
// TODO: In wrap mode all hosts does not need to be sorted
|
|
1695
|
-
|
|
1695
|
+
let dataSource = host.getDataSource();
|
|
1696
1696
|
if (dataSource) {
|
|
1697
|
-
|
|
1697
|
+
let noOptimization = opt_action["isUserAction"] == true;
|
|
1698
1698
|
dataSource.sort(c_ref, orders, sortLogics, noOptimization); // If length === 0 data is not sorted
|
|
1699
1699
|
}
|
|
1700
1700
|
}
|
|
@@ -1706,18 +1706,18 @@ SortableTitlePlugin.prototype._sortDataView = function (opt_action) {
|
|
|
1706
1706
|
* @return {number|null} The column index of cleared sort
|
|
1707
1707
|
*/
|
|
1708
1708
|
SortableTitlePlugin.prototype._clearSortSymbols = function (state) {
|
|
1709
|
-
|
|
1709
|
+
let cells = state["targetCells"];
|
|
1710
1710
|
if (!cells) {
|
|
1711
1711
|
return null;
|
|
1712
1712
|
}
|
|
1713
|
-
|
|
1714
|
-
for (
|
|
1715
|
-
|
|
1713
|
+
let colIndex = null;
|
|
1714
|
+
for (let j = cells.length; --j >= 0;) { // One single cell per host
|
|
1715
|
+
let cell = cells[j];
|
|
1716
1716
|
cell["removeClass"]("sorting");
|
|
1717
1717
|
cell["removeClass"]("sortable");
|
|
1718
1718
|
cell["removeFloatingIcon"]("sort-symbol");
|
|
1719
1719
|
cell["removeFloatingIcon"]("priority-symbol");
|
|
1720
|
-
|
|
1720
|
+
let section;
|
|
1721
1721
|
if(colIndex == null && (section = cell["getSection"]())) {
|
|
1722
1722
|
colIndex = section["getColumnIndex"](cell["getParent"]());
|
|
1723
1723
|
}
|
|
@@ -1731,19 +1731,19 @@ SortableTitlePlugin.prototype._clearSortSymbols = function (state) {
|
|
|
1731
1731
|
* @param {number} hostIndex
|
|
1732
1732
|
*/
|
|
1733
1733
|
SortableTitlePlugin.prototype._updateSortableIndicator = function (hostIndex) {
|
|
1734
|
-
|
|
1735
|
-
|
|
1734
|
+
let t = this;
|
|
1735
|
+
let host = t._hosts[hostIndex];
|
|
1736
1736
|
if (!host || this._frozenIndicator) { return; }
|
|
1737
1737
|
|
|
1738
|
-
|
|
1738
|
+
let section = host.getSection("title");
|
|
1739
1739
|
if (section == null) { return; }
|
|
1740
|
-
|
|
1741
|
-
for (
|
|
1740
|
+
let colCount = section["getColumnCount"]();
|
|
1741
|
+
for (let col = colCount; --col >= 0;) {
|
|
1742
1742
|
|
|
1743
|
-
|
|
1744
|
-
for (
|
|
1743
|
+
let rowCount = section["getRowCount"]();
|
|
1744
|
+
for (let r = 0; r < rowCount; r++) {
|
|
1745
1745
|
|
|
1746
|
-
|
|
1746
|
+
let cell = section["getCell"](col, r, true);
|
|
1747
1747
|
if (!cell) { continue; }
|
|
1748
1748
|
|
|
1749
1749
|
// Clear all sorting icons
|
|
@@ -1761,11 +1761,11 @@ SortableTitlePlugin.prototype._updateSortableIndicator = function (hostIndex) {
|
|
|
1761
1761
|
|
|
1762
1762
|
cell["addClass"]("sortable");
|
|
1763
1763
|
|
|
1764
|
-
|
|
1765
|
-
|
|
1764
|
+
let priority = t.getSortPriority(col);
|
|
1765
|
+
let state = t._sortStates[priority];
|
|
1766
1766
|
|
|
1767
|
-
|
|
1768
|
-
|
|
1767
|
+
let isSorting = state && state["sortOrder"] !== "n";
|
|
1768
|
+
let symbol, icon;
|
|
1769
1769
|
if (isSorting) {
|
|
1770
1770
|
if (!state["targetCells"]) {
|
|
1771
1771
|
state["targetCells"] = [];
|
|
@@ -1781,7 +1781,7 @@ SortableTitlePlugin.prototype._updateSortableIndicator = function (hostIndex) {
|
|
|
1781
1781
|
cell["addClass"]("sorting");
|
|
1782
1782
|
|
|
1783
1783
|
if(t._solarTheme) { // Insert icon when use solar theme
|
|
1784
|
-
|
|
1784
|
+
let textContent;
|
|
1785
1785
|
|
|
1786
1786
|
if (state["sortOrder"] === "a") {
|
|
1787
1787
|
textContent = CODE_UP;
|
|
@@ -1820,7 +1820,7 @@ SortableTitlePlugin.prototype._updateSortableIndicator = function (hostIndex) {
|
|
|
1820
1820
|
* @return {Element}
|
|
1821
1821
|
*/
|
|
1822
1822
|
SortableTitlePlugin.prototype._createIconElem = function (icon, fallback) {
|
|
1823
|
-
|
|
1823
|
+
let elem;
|
|
1824
1824
|
if (!icon || typeof icon !== "string") {
|
|
1825
1825
|
elem = document.createElement("span");
|
|
1826
1826
|
elem.textContent = fallback;
|
|
@@ -1837,7 +1837,7 @@ SortableTitlePlugin.prototype._createIconElem = function (icon, fallback) {
|
|
|
1837
1837
|
*/
|
|
1838
1838
|
SortableTitlePlugin.prototype._getColumnIndex = function (colRef) {
|
|
1839
1839
|
if(colRef != null) {
|
|
1840
|
-
|
|
1840
|
+
let host = this._hosts[0];
|
|
1841
1841
|
if(host) {
|
|
1842
1842
|
if(typeof colRef === "number") {
|
|
1843
1843
|
return colRef;
|
|
@@ -1856,7 +1856,7 @@ SortableTitlePlugin.prototype._getColumnIndex = function (colRef) {
|
|
|
1856
1856
|
* @return {string} column id or empty string for not found
|
|
1857
1857
|
*/
|
|
1858
1858
|
SortableTitlePlugin.prototype._getColumnId = function (colRef) {
|
|
1859
|
-
|
|
1859
|
+
let host = this._hosts[0];
|
|
1860
1860
|
if(host && colRef != null) {
|
|
1861
1861
|
return host.getColumnId(colRef);
|
|
1862
1862
|
}
|
|
@@ -1868,7 +1868,7 @@ SortableTitlePlugin.prototype._getColumnId = function (colRef) {
|
|
|
1868
1868
|
* @return {Object}
|
|
1869
1869
|
*/
|
|
1870
1870
|
SortableTitlePlugin.prototype._getSortOptions = function (colIndex) {
|
|
1871
|
-
|
|
1871
|
+
let host = this._hosts[0];
|
|
1872
1872
|
if (host) {
|
|
1873
1873
|
return host.getColumnData(colIndex)["sortableTitle"] || null;
|
|
1874
1874
|
}
|
|
@@ -1879,10 +1879,10 @@ SortableTitlePlugin.prototype._getSortOptions = function (colIndex) {
|
|
|
1879
1879
|
* @return {!Object}
|
|
1880
1880
|
*/
|
|
1881
1881
|
SortableTitlePlugin.prototype._newSortOptions = function (colIndex) {
|
|
1882
|
-
|
|
1883
|
-
|
|
1882
|
+
let host = this._hosts[0];
|
|
1883
|
+
let sortOptions = null;
|
|
1884
1884
|
if (host && colIndex >= 0) {
|
|
1885
|
-
|
|
1885
|
+
let colData = host.getColumnData(colIndex); // colData is guaranteed to exist
|
|
1886
1886
|
sortOptions = colData["sortableTitle"];
|
|
1887
1887
|
if (!sortOptions) {
|
|
1888
1888
|
sortOptions = colData["sortableTitle"] = {};
|
|
@@ -1897,13 +1897,13 @@ SortableTitlePlugin.prototype._newSortOptions = function (colIndex) {
|
|
|
1897
1897
|
* @return {boolean}
|
|
1898
1898
|
*/
|
|
1899
1899
|
SortableTitlePlugin.prototype._isCellSortable = function (section, colIndex, rowIndex) {
|
|
1900
|
-
|
|
1900
|
+
let options = this._getSortOptions(colIndex);
|
|
1901
1901
|
if (options) {
|
|
1902
1902
|
if (options["disabled"]) {
|
|
1903
1903
|
return false;
|
|
1904
1904
|
}
|
|
1905
1905
|
|
|
1906
|
-
|
|
1906
|
+
let field = options["field"];
|
|
1907
1907
|
if (field != null) {
|
|
1908
1908
|
if (!field) {
|
|
1909
1909
|
return false;
|
|
@@ -1911,16 +1911,16 @@ SortableTitlePlugin.prototype._isCellSortable = function (section, colIndex, row
|
|
|
1911
1911
|
}
|
|
1912
1912
|
}
|
|
1913
1913
|
|
|
1914
|
-
|
|
1914
|
+
let targetCell = section["getCell"](colIndex, rowIndex, true);
|
|
1915
1915
|
if (targetCell.hasClass("no-sort")) {
|
|
1916
1916
|
return false; // The cell is not allowed for sorting
|
|
1917
1917
|
}
|
|
1918
|
-
|
|
1918
|
+
let bottomCell = section["getCell"](colIndex, section["getRowCount"]() - 1, true);
|
|
1919
1919
|
if (targetCell !== bottomCell) {
|
|
1920
1920
|
return false;
|
|
1921
1921
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1922
|
+
let parentCell = targetCell.getParent();
|
|
1923
|
+
let classList = parentCell["classList"];
|
|
1924
1924
|
// "collapsed" class in column element only enable by column stack in spreading mode
|
|
1925
1925
|
if (classList.contains("collapsed")) { // HACK: unsortable for collapsed stack in spreading mode
|
|
1926
1926
|
return false;
|