@refinitiv-ui/efx-grid 6.0.3 → 6.0.4
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 +49 -0
- package/lib/column-dragging/es6/ColumnDragging.js +764 -0
- package/lib/column-dragging/es6/index.d.ts +1 -0
- package/lib/column-dragging/es6/index.js +1 -0
- package/lib/core/dist/core.css +1 -1
- package/lib/core/dist/core.js +389 -1070
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/ColumnStats.d.ts +2 -2
- package/lib/core/es6/data/DataCache.d.ts +4 -4
- package/lib/core/es6/data/DataTable.d.ts +5 -5
- package/lib/core/es6/data/DataTable.js +1 -1
- package/lib/core/es6/data/DataView.d.ts +12 -12
- package/lib/core/es6/data/SegmentCollection.d.ts +3 -3
- package/lib/core/es6/data/WrappedView.d.ts +13 -13
- package/lib/core/es6/grid/Core.d.ts +29 -27
- package/lib/core/es6/grid/Core.js +26 -4
- package/lib/core/es6/grid/ILayoutGrid.d.ts +15 -15
- package/lib/core/es6/grid/LayoutGrid.js +54 -26
- package/lib/core/es6/grid/VirtualizedLayoutGrid.js +66 -0
- package/lib/core/es6/grid/components/Cell.d.ts +4 -4
- package/lib/core/es6/grid/components/CellFloatingPanel.d.ts +1 -1
- package/lib/core/es6/grid/components/CellSpans.d.ts +8 -8
- package/lib/core/es6/grid/components/Column.d.ts +1 -1
- package/lib/core/es6/grid/components/ElementWrapper.d.ts +6 -6
- package/lib/core/es6/grid/components/Scrollbar.d.ts +1 -1
- package/lib/core/es6/grid/components/StretchedCells.js +2 -2
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.d.ts +14 -6
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +147 -81
- package/lib/core/es6/grid/util/Conflator.d.ts +2 -2
- package/lib/core/es6/grid/util/ElementFrameWork.d.ts +3 -3
- package/lib/core/es6/grid/util/HttpRequest.d.ts +2 -2
- package/lib/core/es6/grid/util/PercentBarRenderer.d.ts +1 -1
- package/lib/core/es6/grid/util/RangeBar.d.ts +1 -1
- package/lib/core/es6/grid/util/SectionSettings.d.ts +5 -5
- package/lib/core/es6/grid/util/SectionSettings.js +5 -0
- package/lib/core/es6/grid/util/SelectionList.d.ts +2 -2
- package/lib/core/es6/grid/util/TrackLayout.d.ts +7 -3
- package/lib/core/es6/grid/util/TrackLayout.js +27 -0
- package/lib/core/es6/grid/util/util.d.ts +2 -2
- package/lib/core/es6/index.d.ts +1 -5
- package/lib/core/es6/index.js +1 -7
- package/lib/core/es6/tr-grid-theme.js +1 -1
- package/lib/filter-dialog/lib/filter-dialog.d.ts +1 -0
- package/lib/filter-dialog/lib/filter-dialog.js +73 -26
- package/lib/filter-dialog/themes/base-checkbox.less +8 -1
- package/lib/filter-dialog/themes/base.less +69 -1
- package/lib/filter-dialog/themes/elemental/dark/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/elemental/dark/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/elemental/dark/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/elemental/light/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/elemental/light/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/elemental/light/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/halo/dark/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/halo/dark/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/halo/dark/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/halo/light/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/halo/light/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/halo/light/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/solar/charcoal/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/solar/charcoal/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/solar/charcoal/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/solar/pearl/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/solar/pearl/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/solar/pearl/filter-dialog.js +1 -1
- package/lib/grid/lib/efx-grid.d.ts +8 -5
- package/lib/grid/lib/efx-grid.js +10 -4
- 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 +33 -39
- 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/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/row-segmenting/es6/RowSegmenting.d.ts +7 -2
- package/lib/row-segmenting/es6/RowSegmenting.js +94 -9
- package/lib/rt-grid/dist/rt-grid.js +567 -1171
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/ColumnDefinition.d.ts +5 -3
- package/lib/rt-grid/es6/ColumnDefinition.js +17 -108
- package/lib/rt-grid/es6/DataConnector.d.ts +3 -3
- package/lib/rt-grid/es6/Grid.d.ts +17 -9
- package/lib/rt-grid/es6/Grid.js +201 -101
- package/lib/rt-grid/es6/RowDefSorter.d.ts +19 -0
- package/lib/rt-grid/es6/RowDefSorter.js +137 -0
- package/lib/rt-grid/es6/RowDefinition.d.ts +9 -7
- package/lib/rt-grid/es6/RowDefinition.js +6 -0
- package/lib/rt-grid/es6/SnapshotFiller.d.ts +3 -1
- package/lib/rt-grid/es6/SnapshotFiller.js +23 -0
- package/lib/tr-grid-checkbox/es6/Checkbox.d.ts +2 -2
- package/lib/tr-grid-checkbox/es6/Checkbox.js +38 -20
- package/lib/tr-grid-column-selection/es6/ColumnSelection.js +46 -9
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +8 -4
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +240 -125
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.d.ts +1 -1
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +18 -12
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.d.ts +7 -4
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +93 -2
- package/lib/tr-grid-printer/es6/CellWriter.d.ts +3 -3
- package/lib/tr-grid-printer/es6/GridPrinter.d.ts +1 -1
- package/lib/tr-grid-printer/es6/GridPrinter.js +26 -13
- package/lib/tr-grid-printer/es6/PrintTrait.d.ts +2 -2
- package/lib/tr-grid-printer/es6/SectionWriter.d.ts +3 -3
- package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +2 -1
- package/lib/tr-grid-row-dragging/es6/RowDragging.js +29 -143
- package/lib/tr-grid-row-grouping/es6/RowGrouping.d.ts +7 -2
- package/lib/tr-grid-row-grouping/es6/RowGrouping.js +97 -7
- package/lib/tr-grid-row-selection/es6/RowSelection.js +10 -0
- package/lib/tr-grid-textformatting/es6/TextFormatting.d.ts +1 -1
- package/lib/tr-grid-textformatting/es6/TextFormatting.js +12 -0
- package/lib/tr-grid-util/es6/DragUI.d.ts +16 -0
- package/lib/tr-grid-util/es6/DragUI.js +214 -0
- package/lib/tr-grid-util/es6/ElementObserver.d.ts +2 -0
- package/lib/tr-grid-util/es6/ElementObserver.js +28 -1
- package/lib/tr-grid-util/es6/ElfUtil.js +1 -1
- package/lib/tr-grid-util/es6/FieldFormatter.js +7 -5
- package/lib/tr-grid-util/es6/GridPlugin.js +8 -4
- package/lib/tr-grid-util/es6/NumberFormatter.d.ts +2 -0
- package/lib/tr-grid-util/es6/NumberFormatter.js +64 -19
- package/lib/tr-grid-util/es6/RowPainter.js +41 -11
- package/lib/tr-grid-util/es6/formula/Formula.js +9 -1
- package/lib/types/es6/Checkbox.d.ts +2 -2
- package/lib/types/es6/ColumnStack.d.ts +8 -4
- package/lib/types/es6/CompositeGrid/ColumnSelectionPlugin.d.ts +3 -2
- package/lib/types/es6/CompositeGrid/ColumnWidthAdjustingPlugin.d.ts +2 -1
- package/lib/types/es6/CompositeGrid/CompositeGrid.d.ts +20 -18
- package/lib/types/es6/CompositeGrid/DragAndDropTitlePlugin.d.ts +2 -1
- package/lib/types/es6/CompositeGrid/DraggableContentPlugin.d.ts +3 -2
- package/lib/types/es6/CompositeGrid/Plugin.d.ts +28 -0
- package/lib/types/es6/CompositeGrid/ResizableTitlePlugin.d.ts +2 -1
- package/lib/types/es6/CompositeGrid/RowSelectionPlugin.d.ts +5 -4
- package/lib/types/es6/CompositeGrid/TreeIndentingPlugin.d.ts +2 -1
- package/lib/types/es6/CompositeGrid/index.d.ts +9 -9
- package/lib/types/es6/ConditionalColoring.d.ts +1 -1
- package/lib/types/es6/Core/data/ColumnStats.d.ts +2 -2
- package/lib/types/es6/Core/data/DataCache.d.ts +4 -4
- package/lib/types/es6/Core/data/DataTable.d.ts +5 -5
- package/lib/types/es6/Core/data/DataView.d.ts +12 -12
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +3 -3
- package/lib/types/es6/Core/data/WrappedView.d.ts +13 -13
- package/lib/types/es6/Core/grid/Core.d.ts +29 -27
- package/lib/types/es6/Core/grid/ILayoutGrid.d.ts +15 -15
- package/lib/types/es6/Core/grid/components/Cell.d.ts +4 -4
- package/lib/types/es6/Core/grid/components/CellFloatingPanel.d.ts +1 -1
- package/lib/types/es6/Core/grid/components/CellSpans.d.ts +8 -8
- package/lib/types/es6/Core/grid/components/Column.d.ts +1 -1
- package/lib/types/es6/Core/grid/components/ElementWrapper.d.ts +6 -6
- package/lib/types/es6/Core/grid/components/Scrollbar.d.ts +1 -1
- package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +14 -6
- package/lib/types/es6/Core/grid/util/Conflator.d.ts +2 -2
- package/lib/types/es6/Core/grid/util/ElementFrameWork.d.ts +3 -3
- package/lib/types/es6/Core/grid/util/HttpRequest.d.ts +2 -2
- package/lib/types/es6/Core/grid/util/PercentBarRenderer.d.ts +1 -1
- package/lib/types/es6/Core/grid/util/RangeBar.d.ts +1 -1
- package/lib/types/es6/Core/grid/util/SectionSettings.d.ts +5 -5
- package/lib/types/es6/Core/grid/util/SelectionList.d.ts +2 -2
- package/lib/types/es6/Core/grid/util/TrackLayout.d.ts +7 -3
- package/lib/types/es6/Core/grid/util/util.d.ts +2 -2
- package/lib/types/es6/Core/index.d.ts +1 -5
- package/lib/types/es6/ExtensionOptions.d.ts +2 -0
- package/lib/types/es6/InCellEditing.d.ts +7 -4
- package/lib/types/es6/RealtimeGrid/ColumnDefinition.d.ts +5 -3
- package/lib/types/es6/RealtimeGrid/DataConnector.d.ts +3 -3
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +17 -9
- package/lib/types/es6/RealtimeGrid/RowDefSorter.d.ts +19 -0
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +9 -7
- package/lib/types/es6/RealtimeGrid/SnapshotFiller.d.ts +3 -1
- package/lib/types/es6/RowDragging.d.ts +2 -1
- package/lib/types/es6/RowGrouping.d.ts +7 -2
- package/lib/types/es6/RowSegmenting.d.ts +7 -2
- package/lib/types/es6/TextFormatting.d.ts +1 -1
- package/lib/versions.json +14 -13
- package/package.json +1 -1
- package/lib/core/es6/grid/plugins/DragAndDropTitlePlugin.d.ts +0 -24
- package/lib/core/es6/grid/plugins/DragAndDropTitlePlugin.js +0 -615
- package/lib/core/es6/grid/plugins/Plugin.d.ts +0 -28
- package/lib/core/es6/grid/plugins/Plugin.js +0 -272
- package/lib/types/es6/Core/grid/plugins/DragAndDropTitlePlugin.d.ts +0 -24
- package/lib/types/es6/Core/grid/plugins/Plugin.d.ts +0 -28
package/lib/core/dist/core.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
/******/ "use strict";
|
3
3
|
var __webpack_exports__ = {};
|
4
4
|
|
5
|
-
// UNUSED EXPORTS: Cell, CellFloatingPanel, CellSpan, CellSpans, Column, ColumnStats, Conflator, Core, DataCache, DataTable, DataView,
|
5
|
+
// UNUSED EXPORTS: Cell, CellFloatingPanel, CellSpan, CellSpans, Column, ColumnStats, Conflator, Core, DataCache, DataTable, DataView, ElementFrameWork, ElementWrapper, EventDispatcher, HScrollbar, ILayoutGrid, LayoutGrid, Reverter, Scrollbar, SectionSettings, SelectionList, SortableTitlePlugin, TrackLayout, VScrollbar, VirtualizedLayoutGrid, Virtualizer, default
|
6
6
|
|
7
7
|
;// CONCATENATED MODULE: ./src/js/grid/util/util.js
|
8
8
|
/**
|
@@ -3031,6 +3031,33 @@ TrackLayout.prototype.setLaneSize = function (index, val) {
|
|
3031
3031
|
return false;
|
3032
3032
|
};
|
3033
3033
|
|
3034
|
+
/** @public
|
3035
|
+
* @param {number} index
|
3036
|
+
* @param {string} propName
|
3037
|
+
* @param {*} val
|
3038
|
+
* @return {boolean}
|
3039
|
+
*/
|
3040
|
+
TrackLayout.prototype.setLaneProperty = function (index, propName, val) {
|
3041
|
+
if (index < 0 || index >= this._laneCount) { return false; }
|
3042
|
+
|
3043
|
+
var col = this._cols[index];
|
3044
|
+
if (col == null || col[propName] !== val) {
|
3045
|
+
col = this._newColumn(index);
|
3046
|
+
col[propName] = val;
|
3047
|
+
return true;
|
3048
|
+
}
|
3049
|
+
|
3050
|
+
return false;
|
3051
|
+
};
|
3052
|
+
/** @public
|
3053
|
+
* @param {number} index
|
3054
|
+
* @param {string} propName
|
3055
|
+
* @return {*}
|
3056
|
+
*/
|
3057
|
+
TrackLayout.prototype.getLaneProperty = function (index, propName) {
|
3058
|
+
var col = this._cols[index];
|
3059
|
+
return (col && col[propName] != null) ? col[propName] : null;
|
3060
|
+
};
|
3034
3061
|
/** @public
|
3035
3062
|
* @param {number} index
|
3036
3063
|
* @return {number}
|
@@ -5017,10 +5044,10 @@ StretchedCells.prototype.getColumnIndex = function (cellRef) {
|
|
5017
5044
|
if(cellRef["getElement"]) {
|
5018
5045
|
var cellElement = cellRef["getElement"]();
|
5019
5046
|
if(cellElement) {
|
5020
|
-
return cellElement._colIndex
|
5047
|
+
return cellElement._colIndex != null ? cellElement._colIndex : -1;
|
5021
5048
|
}
|
5022
5049
|
} else {
|
5023
|
-
return cellRef._colIndex
|
5050
|
+
return cellRef._colIndex != null ? cellRef._colIndex : -1;
|
5024
5051
|
}
|
5025
5052
|
}
|
5026
5053
|
return -1;
|
@@ -8280,6 +8307,22 @@ LayoutGrid.prototype._setColumnWidth = function (indexX, val) {
|
|
8280
8307
|
LayoutGrid.prototype._updateColumnLayout = function () {
|
8281
8308
|
this._syncLayoutToColumns(0);
|
8282
8309
|
};
|
8310
|
+
/** @public
|
8311
|
+
* @ignore
|
8312
|
+
* @param {boolean} enabled
|
8313
|
+
* @param {number=} fromR
|
8314
|
+
* @param {number=} toR
|
8315
|
+
*/
|
8316
|
+
LayoutGrid.prototype._startBindingSession = function (enabled, fromR, toR) {
|
8317
|
+
// Prevent error when calling _startBindingSession in LayoutGrid
|
8318
|
+
};
|
8319
|
+
/** @public
|
8320
|
+
* @ignore
|
8321
|
+
* @return {Array<boolean>}
|
8322
|
+
*/
|
8323
|
+
LayoutGrid.prototype._getTempRowHeights = function () {
|
8324
|
+
return null;
|
8325
|
+
};
|
8283
8326
|
|
8284
8327
|
/**
|
8285
8328
|
* {@link ILayoutGrid#getRowHeight}
|
@@ -9121,6 +9164,11 @@ LayoutGrid.prototype.setRowHighlight = function (rowIndex) {
|
|
9121
9164
|
this._highlightedCells[c] = cell;
|
9122
9165
|
cell.addClass("highlighted-row");
|
9123
9166
|
}
|
9167
|
+
var stretchEl = this.getStretchedCell(rowIndex); // check stretched cell
|
9168
|
+
if(stretchEl) {
|
9169
|
+
this._highlightedCells.push(stretchEl);
|
9170
|
+
stretchEl.addClass("highlighted-row");
|
9171
|
+
}
|
9124
9172
|
} else {
|
9125
9173
|
this._highlightedCells.length = 0;
|
9126
9174
|
}
|
@@ -9406,6 +9454,7 @@ LayoutGrid.prototype.insertColumn = function (index, opt_json) {
|
|
9406
9454
|
cell.addClass("selected-row");
|
9407
9455
|
}
|
9408
9456
|
}
|
9457
|
+
// TODO: Check if it can insert column with stretch cell
|
9409
9458
|
}
|
9410
9459
|
|
9411
9460
|
column.activate(atTheMiddle || !this._colVir);
|
@@ -9637,6 +9686,10 @@ LayoutGrid.prototype.stretchCell = function (cellRef, rowIndex, opt_stretching,
|
|
9637
9686
|
} else {
|
9638
9687
|
cell = this._stretchedCells.unstretchCell(rowIndex);
|
9639
9688
|
}
|
9689
|
+
if(cell) {
|
9690
|
+
var selected = this._selectionList.getSelection(rowIndex);
|
9691
|
+
cell.enableClass("selected-row", selected); // It's can enable class without get stretch cell again.
|
9692
|
+
}
|
9640
9693
|
return cell;
|
9641
9694
|
};
|
9642
9695
|
|
@@ -9719,6 +9772,19 @@ LayoutGrid.prototype._calculateViewSize = function (forceRecal) {
|
|
9719
9772
|
}
|
9720
9773
|
return stretchSize;
|
9721
9774
|
};
|
9775
|
+
|
9776
|
+
/**
|
9777
|
+
* @private
|
9778
|
+
* @param {number} rowIndex
|
9779
|
+
* @param {string} className
|
9780
|
+
* @param {boolean} enabled
|
9781
|
+
*/
|
9782
|
+
LayoutGrid.prototype._enableStretchCellClass = function (rowIndex, className, enabled ) {
|
9783
|
+
var stretchEl = this.getStretchedCell(rowIndex); // check stretched cell
|
9784
|
+
if(stretchEl) {
|
9785
|
+
stretchEl.enableClass(className, enabled);
|
9786
|
+
}
|
9787
|
+
};
|
9722
9788
|
/** View size is width of container (Grid's pane) or content (LayoutGrid's columns), whichever is smaller.
|
9723
9789
|
* @public
|
9724
9790
|
* @ignore
|
@@ -10402,11 +10468,16 @@ LayoutGrid.prototype._updateCellSpans = function (cellSpans, adding) {
|
|
10402
10468
|
*/
|
10403
10469
|
LayoutGrid.prototype._onMouseMove = function (e) {
|
10404
10470
|
var target = e["target"];
|
10405
|
-
var colElement = util.closestElement(target, "column");
|
10406
|
-
var colIndex = this.getColumnIndex(colElement);
|
10407
|
-
var cellElement = (colIndex >= 0) ? util.closestElement(target, "cell") : null;
|
10408
10471
|
|
10409
|
-
|
10472
|
+
var cellElement = util.closestElement(target, "cell");
|
10473
|
+
var colIndex = this._stretchedCells.getColumnIndex(cellElement);
|
10474
|
+
if(colIndex < 0) { // Not found colIndex in stretching cell, then get from normal row
|
10475
|
+
var colElement = util.closestElement(target, "column");
|
10476
|
+
colIndex = this.getColumnIndex(colElement);
|
10477
|
+
}
|
10478
|
+
var rowIndex = this.getCellIndex(colIndex, cellElement);
|
10479
|
+
|
10480
|
+
this.setRowHighlight(rowIndex);
|
10410
10481
|
};
|
10411
10482
|
|
10412
10483
|
/**
|
@@ -10437,27 +10508,16 @@ LayoutGrid.prototype._onMouseOut = function (e) {
|
|
10437
10508
|
*/
|
10438
10509
|
LayoutGrid.prototype._updateSelectionUI = function (rowIndex) { // Update UI of the specified row index
|
10439
10510
|
var selected = this._selectionList.getSelection(rowIndex);
|
10440
|
-
|
10441
|
-
|
10442
|
-
var cell = this._columns[c].getCell(rowIndex);
|
10443
|
-
|
10444
|
-
if (cell) {
|
10445
|
-
cell.enableClass("selected-row", selected);
|
10446
|
-
}
|
10447
|
-
}
|
10511
|
+
this._enableStretchCellClass(rowIndex, "selected-row", selected);
|
10512
|
+
this.enableRowClass(rowIndex, "selected-row", selected);
|
10448
10513
|
};
|
10449
10514
|
|
10450
10515
|
/** @private
|
10451
10516
|
* @param {number} rowIndex
|
10452
10517
|
*/
|
10453
10518
|
LayoutGrid.prototype._addSelectionUI = function (rowIndex) {
|
10454
|
-
|
10455
|
-
|
10456
|
-
|
10457
|
-
if (cell) {
|
10458
|
-
cell.addClass("selected-row");
|
10459
|
-
}
|
10460
|
-
}
|
10519
|
+
this._enableStretchCellClass(rowIndex, "selected-row", true);
|
10520
|
+
this.enableRowClass(rowIndex, "selected-row", true);
|
10461
10521
|
};
|
10462
10522
|
|
10463
10523
|
/**
|
@@ -10465,13 +10525,8 @@ LayoutGrid.prototype._addSelectionUI = function (rowIndex) {
|
|
10465
10525
|
* @param {number} rowIndex
|
10466
10526
|
*/
|
10467
10527
|
LayoutGrid.prototype._removeSelectionUI = function (rowIndex) {
|
10468
|
-
|
10469
|
-
|
10470
|
-
|
10471
|
-
if (cell) {
|
10472
|
-
cell.removeClass("selected-row");
|
10473
|
-
}
|
10474
|
-
}
|
10528
|
+
this._enableStretchCellClass(rowIndex, "selected-row", false);
|
10529
|
+
this.enableRowClass(rowIndex, "selected-row", false);
|
10475
10530
|
};
|
10476
10531
|
|
10477
10532
|
/**
|
@@ -13326,7 +13381,7 @@ DataTable.prototype.setColumnSortingLogic = function(cid, func) {
|
|
13326
13381
|
* @example
|
13327
13382
|
* var prevState = dt.freeze();
|
13328
13383
|
* for(var i = 0; i < 100; ++i) {
|
13329
|
-
* dt.insertRow(
|
13384
|
+
* dt.insertRow(); // no event is fired
|
13330
13385
|
* }
|
13331
13386
|
* dt.freeze(prevState); // Restore previous freeze states
|
13332
13387
|
*/
|
@@ -20614,6 +20669,11 @@ SectionSettings.prototype._dispatchDataChanged = function (firstUpdate, lastUpda
|
|
20614
20669
|
*/
|
20615
20670
|
SectionSettings.prototype.updateRowData = function (fromRowIndex, lastRowIndex, e) {
|
20616
20671
|
if(this.isDataBindable()) { // Prevent dispatching dataChanged event without the data view
|
20672
|
+
if(this._grid._getTempRowHeights()){
|
20673
|
+
fromRowIndex = this._grid.getFirstIndexInView();
|
20674
|
+
lastRowIndex = this._grid.getLastIndexInView() + 1;
|
20675
|
+
}
|
20676
|
+
|
20617
20677
|
e = this.extendDataEventArg(e, fromRowIndex, lastRowIndex);
|
20618
20678
|
if(e["fromRowIndex"] < e["toRowIndex"]) {
|
20619
20679
|
this._dispatch("dataChanged", e);
|
@@ -21374,6 +21434,14 @@ VirtualizedLayoutGrid.prototype._boundLayer = null;
|
|
21374
21434
|
* @private
|
21375
21435
|
*/
|
21376
21436
|
VirtualizedLayoutGrid.prototype._hscrollbar = null;
|
21437
|
+
/** @type {string}
|
21438
|
+
* @private
|
21439
|
+
*/
|
21440
|
+
VirtualizedLayoutGrid.prototype._session = "A";
|
21441
|
+
/** @type {Array<boolean>}
|
21442
|
+
* @private
|
21443
|
+
*/
|
21444
|
+
VirtualizedLayoutGrid.prototype._tempRowHeights = null;
|
21377
21445
|
|
21378
21446
|
//#region ====== Override ElementWrapper ======//
|
21379
21447
|
/** @override */
|
@@ -21485,13 +21553,68 @@ VirtualizedLayoutGrid.prototype._setColumnWidth = function (indexX, val) {
|
|
21485
21553
|
VirtualizedLayoutGrid.prototype._updateColumnLayout = function () {
|
21486
21554
|
this._grid._updateColumnLayout();
|
21487
21555
|
};
|
21556
|
+
/** @public
|
21557
|
+
* @ignore
|
21558
|
+
* @param {boolean} enabled
|
21559
|
+
*/
|
21560
|
+
VirtualizedLayoutGrid.prototype._startBindingSession = function (enabled) {
|
21561
|
+
this._isBinding = enabled;
|
21562
|
+
if(!enabled){
|
21563
|
+
// Clear old session
|
21564
|
+
if(this._tempRowHeights){
|
21565
|
+
var defaultRowHeight = this.getDefaultRowHeight();
|
21566
|
+
var hasSession = true;
|
21567
|
+
var removedIndices = [];
|
21568
|
+
|
21569
|
+
for(var key in this._tempRowHeights){
|
21570
|
+
var index = +key;
|
21571
|
+
var rowSession = this._layoutY.getLaneProperty(index, "sizeSession");
|
21572
|
+
if(rowSession) {
|
21573
|
+
if(rowSession != this._session){
|
21574
|
+
this.setRowHeight(index, defaultRowHeight);
|
21575
|
+
this._layoutY.setLaneProperty(index, "sizeSession", null);
|
21576
|
+
removedIndices.push(index);
|
21577
|
+
}
|
21578
|
+
}
|
21579
|
+
}
|
21580
|
+
var removedCount = removedIndices.length;
|
21581
|
+
for(var i = 0; i < removedCount; i++){
|
21582
|
+
delete this._tempRowHeights[removedIndices[i]];
|
21583
|
+
}
|
21584
|
+
if(removedCount){
|
21585
|
+
for(var remainingKey in this._tempRowHeights){
|
21586
|
+
hasSession = remainingKey != null;
|
21587
|
+
break;
|
21588
|
+
}
|
21589
|
+
}
|
21590
|
+
if(!hasSession){
|
21591
|
+
this._tempRowHeights = null;
|
21592
|
+
}
|
21488
21593
|
|
21594
|
+
}
|
21595
|
+
this._session = this._session === "A" ? "B" : "A";
|
21596
|
+
}
|
21597
|
+
};
|
21598
|
+
/** @public
|
21599
|
+
* @ignore
|
21600
|
+
* @return {Array<boolean>}
|
21601
|
+
*/
|
21602
|
+
VirtualizedLayoutGrid.prototype._getTempRowHeights = function () {
|
21603
|
+
return this._tempRowHeights;
|
21604
|
+
};
|
21489
21605
|
/** @inheritDoc */
|
21490
21606
|
VirtualizedLayoutGrid.prototype.getRowHeight = function (index) {
|
21491
21607
|
return this._layoutY.getLaneSize(index);
|
21492
21608
|
};
|
21493
21609
|
/** @inheritDoc */
|
21494
21610
|
VirtualizedLayoutGrid.prototype.setRowHeight = function (index, val) {
|
21611
|
+
if(this._isBinding && val != this.getDefaultRowHeight()){
|
21612
|
+
this._layoutY.setLaneProperty(index, "sizeSession", this._session);
|
21613
|
+
if(!this._tempRowHeights){
|
21614
|
+
this._tempRowHeights = [];
|
21615
|
+
}
|
21616
|
+
this._tempRowHeights[index] = true; // Store row index that set temporary row height
|
21617
|
+
}
|
21495
21618
|
if(this._layoutY.setLaneSize(index, val)) {
|
21496
21619
|
this._grid.setRowHeight(index - this._firstIndex, val);
|
21497
21620
|
this._element.style.height = this._layoutY.getTrackSize() + "px";
|
@@ -21645,6 +21768,9 @@ VirtualizedLayoutGrid.prototype.setRowCount = function (val, noBinding) {
|
|
21645
21768
|
var prevCount = this._layoutY.getLaneCount();
|
21646
21769
|
if(prevCount !== val){
|
21647
21770
|
this._layoutY.setLaneCount(val);
|
21771
|
+
if(this._tempRowHeights){
|
21772
|
+
this._tempRowHeights.length = val;
|
21773
|
+
}
|
21648
21774
|
this._element.style.height = this._layoutY.getTrackSize() + "px";
|
21649
21775
|
this._requestUpdatingRowBounds();
|
21650
21776
|
//After rowCountChanged fires, virtualizer will update virtual row count if
|
@@ -22533,6 +22659,7 @@ var Core_Core = function (opt_initializer) {
|
|
22533
22659
|
_t._updateColumnBounds = _t._updateColumnBounds.bind(_t);
|
22534
22660
|
_t._dispatchColumnPositionChanged = _t._dispatchColumnPositionChanged.bind(_t);
|
22535
22661
|
_t._dispatchRowPositionChanged = _t._dispatchRowPositionChanged.bind(_t);
|
22662
|
+
_t._requestScrollbarUpdate = _t._requestScrollbarUpdate.bind(_t);
|
22536
22663
|
|
22537
22664
|
// Text nodes are unintentionally getting in the tag.
|
22538
22665
|
if(opt_initializer) { // Any node other than element node is not allowed within the tag.
|
@@ -22950,6 +23077,10 @@ Core_Core.prototype._preserveProportion = false;
|
|
22950
23077
|
* @private
|
22951
23078
|
*/
|
22952
23079
|
Core_Core.prototype._preserveGridSize = false;
|
23080
|
+
/** @type {number}
|
23081
|
+
* @private
|
23082
|
+
*/
|
23083
|
+
Core_Core.prototype._rowHeightTimerId = 0;
|
22953
23084
|
//#region Public Methods
|
22954
23085
|
|
22955
23086
|
/**
|
@@ -22957,7 +23088,7 @@ Core_Core.prototype._preserveGridSize = false;
|
|
22957
23088
|
* @return {string}
|
22958
23089
|
*/
|
22959
23090
|
Core_Core.getVersion = function () {
|
22960
|
-
return "5.0.
|
23091
|
+
return "5.0.58";
|
22961
23092
|
};
|
22962
23093
|
/** {@link ElementWrapper#dispose}
|
22963
23094
|
* @override
|
@@ -25910,6 +26041,13 @@ Core_Core.prototype.requestRowRefresh = function() {
|
|
25910
26041
|
this._rowRefreshTimer = setTimeout(this._onRowRefresh, 100);
|
25911
26042
|
}
|
25912
26043
|
};
|
26044
|
+
/** Set a timer to call updateScrollbarHeight only once to avoid performance issue due to multiple call of _updateScrollbarHeight()
|
26045
|
+
* @public
|
26046
|
+
*/
|
26047
|
+
Core_Core.prototype._requestScrollbarUpdate = function() {
|
26048
|
+
this._updateScrollbarHeight(true, true);
|
26049
|
+
this._rowHeightTimerId = 0;
|
26050
|
+
};
|
25913
26051
|
|
25914
26052
|
/** prevent bind data process
|
25915
26053
|
* @public
|
@@ -26805,6 +26943,9 @@ Core_Core.prototype._onSectionDataChanged = function (e) {
|
|
26805
26943
|
var dataView = /** @type{DataView} */(e["dataSource"]);
|
26806
26944
|
var hasDataView = (dataView && dataView.getDataSource()) ? 1 : 0;
|
26807
26945
|
var rids, rowDataCollection;
|
26946
|
+
|
26947
|
+
section._startBindingSession(true);
|
26948
|
+
|
26808
26949
|
if(hasDataView) {
|
26809
26950
|
rids = dataView.getVisibleRowIds(true);
|
26810
26951
|
rowDataCollection = dataView.getMultipleRowData(rids, fromR, toR);
|
@@ -26842,8 +26983,9 @@ Core_Core.prototype._onSectionDataChanged = function (e) {
|
|
26842
26983
|
}
|
26843
26984
|
|
26844
26985
|
this._dispatch("postSectionDataBinding", e);
|
26845
|
-
|
26846
26986
|
this._dispatchRowExpansionBinding(e);
|
26987
|
+
|
26988
|
+
section._startBindingSession(false);
|
26847
26989
|
this._dispatchingDataChanged = false;
|
26848
26990
|
};
|
26849
26991
|
|
@@ -27169,8 +27311,14 @@ Core_Core.prototype._onRowHeightChanged = function (e) {
|
|
27169
27311
|
this._rowHeightConflator._needScrollbarUpdate = false;
|
27170
27312
|
this._updateScrollbarHeight(true, true);
|
27171
27313
|
} else if(minSectionIndex >= 0) {
|
27172
|
-
|
27173
|
-
|
27314
|
+
if(this._dispatchingDataChanged){
|
27315
|
+
if(!this._rowHeightTimerId){
|
27316
|
+
this._rowHeightTimerId = setTimeout(this._requestScrollbarUpdate, 0);
|
27317
|
+
}
|
27318
|
+
} else {
|
27319
|
+
this._updateScrollbarHeight(minSectionIndex < this._startVScrollbarIndex,
|
27320
|
+
minSectionIndex >= this._startVScrollbarIndex);
|
27321
|
+
}
|
27174
27322
|
}
|
27175
27323
|
|
27176
27324
|
this._dispatchRowPositionChanged();
|
@@ -27626,985 +27774,94 @@ Core_Core._proto = Core_Core.prototype;
|
|
27626
27774
|
/* harmony default export */ const grid_Core = (Core_Core);
|
27627
27775
|
|
27628
27776
|
|
27629
|
-
;// CONCATENATED MODULE: ./src/js/grid/plugins/
|
27777
|
+
;// CONCATENATED MODULE: ./src/js/grid/plugins/SortableTitlePlugin.js
|
27778
|
+
/* eslint-disable */
|
27630
27779
|
|
27631
27780
|
|
27632
|
-
// eslint-disable-line
|
27633
27781
|
|
27634
|
-
// eslint-disable-line
|
27635
27782
|
|
27636
27783
|
|
27637
|
-
/** Base class for all built-in plugins
|
27638
|
-
* @constructor
|
27639
|
-
* @extends {EventDispatcher}
|
27640
|
-
*/
|
27641
|
-
var Plugin = function () {
|
27642
|
-
/* throw("Plugin is an abstract Class"); */
|
27643
|
-
};
|
27644
|
-
es6_Ext.inherits(Plugin, event_EventDispatcher); // Inherits() will replace prototype of the derived object
|
27645
27784
|
|
27646
|
-
|
27647
|
-
/**The name must be readonly and unique among all other plugins
|
27648
|
-
* @public
|
27649
|
-
* @return {string}
|
27650
|
-
*/
|
27651
|
-
Plugin.prototype.getName = function () {
|
27652
|
-
return "Plugin";
|
27653
|
-
};
|
27785
|
+
/* eslint-enable */
|
27654
27786
|
|
27655
|
-
/**
|
27656
|
-
* @
|
27657
|
-
|
27658
|
-
|
27659
|
-
|
27660
|
-
|
27661
|
-
|
27662
|
-
*
|
27663
|
-
* @param {!Core} owner
|
27787
|
+
/** Fired when user click and before the sorting operation.
|
27788
|
+
* @event SortableTitlePlugin#preClicked
|
27789
|
+
* @property {number} colIndex
|
27790
|
+
* @property {Element} target Element being clicked
|
27791
|
+
* @example
|
27792
|
+
* function onPreClicked(e) {
|
27793
|
+
* e.cancel = true; // Cancel sorting operation
|
27794
|
+
* }
|
27664
27795
|
*/
|
27665
|
-
Plugin.prototype.unload = function (owner) {
|
27666
|
-
this._host = null;
|
27667
|
-
this.unlistenAll();
|
27668
|
-
};
|
27669
27796
|
|
27670
|
-
/**
|
27671
|
-
* @
|
27672
|
-
* @
|
27797
|
+
/** Fired when user click and after the sorting operation
|
27798
|
+
* @event SortableTitlePlugin#clicked
|
27799
|
+
* @property {number} colIndex
|
27800
|
+
* @property {string} sortOrder "a" for "ascending, "d" for descending, and "n" for none
|
27801
|
+
* @property {string} dataColumnName Field that is used for sorting
|
27673
27802
|
*/
|
27674
|
-
Plugin.prototype.getRelativeGrid = function (e) {
|
27675
|
-
var targetEl;
|
27676
|
-
if(e.target) { // The Given object is an Event
|
27677
|
-
targetEl = /** @type{Element} */(e.target);
|
27678
|
-
var gridAPI = targetEl["api"];
|
27679
|
-
if(gridAPI && gridAPI["getCoreGrid"]) {
|
27680
|
-
return /** @type{Core} */(gridAPI["getCoreGrid"]());
|
27681
|
-
}
|
27682
|
-
} else if(e["getElement"]) { // The Given object is implementing ElementWrapper
|
27683
|
-
targetEl = e["getElement"]();
|
27684
|
-
} else if(util.isElement(e)){ // The Given object is just an element
|
27685
|
-
targetEl = /** @type{Element} */(e);
|
27686
|
-
}
|
27687
27803
|
|
27688
|
-
|
27689
|
-
|
27690
|
-
|
27691
|
-
|
27692
|
-
return this._host;
|
27693
|
-
}
|
27694
|
-
} else {
|
27695
|
-
var hostLength = this._hosts ? this._hosts.length : 0;
|
27696
|
-
for (var i = 0; i < hostLength; i++) {
|
27697
|
-
var host = this._hosts[i];
|
27698
|
-
if (host.getElement() === gridEl) {
|
27699
|
-
return host;
|
27700
|
-
}
|
27701
|
-
}
|
27702
|
-
}
|
27703
|
-
}
|
27804
|
+
/** Fired just before sorting data. This allows additional modification before the actual sorting
|
27805
|
+
* @event SortableTitlePlugin#preDataSorting
|
27806
|
+
* @property {boolean=} isUserAction This has true value, if event initiate from clicking title/header section
|
27807
|
+
*/
|
27704
27808
|
|
27705
|
-
|
27706
|
-
|
27707
|
-
|
27708
|
-
* @
|
27709
|
-
* @
|
27710
|
-
* @
|
27711
|
-
* @
|
27809
|
+
/** Fired once column is sorted and before {@link SortableTitlePlugin#clicked}
|
27810
|
+
* @event SortableTitlePlugin#columnSorted
|
27811
|
+
* @property {number} colIndex
|
27812
|
+
* @property {string} sortOrder "a" for "ascending, "d" for descending, and "n" for none
|
27813
|
+
* @property {string} sortedField Field that is used for sorting
|
27814
|
+
* @property {Array.<number>} colIndices An array of colIndex
|
27815
|
+
* @property {Array.<string>} sortOrders An array of sortOrder
|
27816
|
+
* @property {Array.<string>} sortedFields An array of sortedField
|
27712
27817
|
*/
|
27713
|
-
Plugin.prototype.getGridElementFromPoint = function (x, y) {
|
27714
|
-
var elem = document.elementFromPoint(x, y);
|
27715
|
-
var grid = util.closestElement(elem, "tr-grid");
|
27716
27818
|
|
27717
|
-
|
27718
|
-
|
27719
|
-
|
27720
|
-
|
27721
|
-
|
27722
|
-
|
27723
|
-
|
27724
|
-
|
27819
|
+
/** @constructor
|
27820
|
+
* @extends {EventDispatcher}
|
27821
|
+
* @param {SortableTitlePlugin.Options=} options
|
27822
|
+
*/
|
27823
|
+
var SortableTitlePlugin = function (options) { // TODO: Extract SortableTitlePlugin to grid extension.
|
27824
|
+
var _t = this;
|
27825
|
+
_t._onSectionAdded = _t._onSectionAdded.bind(_t);
|
27826
|
+
_t._onMouseDown = _t._onMouseDown.bind(_t);
|
27725
27827
|
|
27726
|
-
|
27727
|
-
}
|
27728
|
-
for (var i = 0; i < skipElem.length; i++) {
|
27729
|
-
skipElem[i].style.visibility = skipVisibility[i];
|
27730
|
-
}
|
27731
|
-
return grid;
|
27732
|
-
};
|
27828
|
+
_t._onUIUpdated = _t._onUIUpdated.bind(_t);
|
27733
27829
|
|
27734
|
-
|
27830
|
+
_t._onColumnAdded = _t._onColumnAdded.bind(_t);
|
27831
|
+
_t._onColumnRemoved = _t._onColumnRemoved.bind(_t);
|
27832
|
+
_t._onItemSortingClicked = _t._onItemSortingClicked.bind(_t);
|
27833
|
+
_t.refresh = _t.refresh.bind(_t);
|
27735
27834
|
|
27736
|
-
|
27737
|
-
|
27738
|
-
* @ignore
|
27739
|
-
* @return {Array.<string>}
|
27740
|
-
*/
|
27741
|
-
Plugin.prototype._getDataColumnMap = function () {
|
27742
|
-
if (this._dataMap) { return this._dataMap; }
|
27835
|
+
_t._hosts = [];
|
27836
|
+
_t._sortLogic = {};
|
27743
27837
|
|
27744
|
-
|
27745
|
-
|
27746
|
-
|
27747
|
-
|
27748
|
-
|
27749
|
-
|
27750
|
-
return null;
|
27751
|
-
};
|
27752
|
-
/** @protected
|
27753
|
-
* @ignore
|
27754
|
-
* @param {number} colIndex
|
27755
|
-
* @return {string}
|
27756
|
-
*/
|
27757
|
-
Plugin.prototype._getDataColumnName = function (colIndex) {
|
27758
|
-
var dataMap = this._getDataColumnMap();
|
27759
|
-
if(dataMap){
|
27760
|
-
return dataMap[colIndex] || "";
|
27761
|
-
}
|
27762
|
-
return "";
|
27763
|
-
};
|
27838
|
+
_t._addEvents(
|
27839
|
+
"preClicked"
|
27840
|
+
, "clicked"
|
27841
|
+
, "preDataSorting"
|
27842
|
+
, "columnSorted"
|
27843
|
+
);
|
27764
27844
|
|
27765
|
-
|
27766
|
-
|
27767
|
-
* @param {Object} e
|
27768
|
-
* @return {boolean}
|
27769
|
-
*/
|
27770
|
-
Plugin.prototype._isNotFirstHost = function(e) {
|
27771
|
-
if (this._hosts) {
|
27772
|
-
return e["sender"] !== this._hosts[0];
|
27773
|
-
}
|
27774
|
-
return false;
|
27775
|
-
};
|
27776
|
-
/** @protected
|
27777
|
-
* @ignore
|
27778
|
-
* @param {Object} e
|
27779
|
-
*/
|
27780
|
-
Plugin.prototype._onColumnAdded = function (e) {
|
27781
|
-
if (this._isNotFirstHost(e)) {
|
27782
|
-
return;
|
27783
|
-
}
|
27784
|
-
if (!e["atTheMiddle"]) { return; }
|
27785
|
-
var colIndex = /** @type{number} */(e["colIndex"]);
|
27786
|
-
util.insertArrayItem(this._colData, colIndex, null);
|
27787
|
-
util.insertArrayItem(this._dataMap, colIndex, null);
|
27788
|
-
};
|
27789
|
-
/** @protected
|
27790
|
-
* @ignore
|
27791
|
-
* @param {Object} e
|
27792
|
-
*/
|
27793
|
-
Plugin.prototype._onColumnMoved = function (e) {
|
27794
|
-
if (this._isNotFirstHost(e)) {
|
27795
|
-
return;
|
27796
|
-
}
|
27797
|
-
var from = /** @type{number} */(e["fromColIndex"]);
|
27798
|
-
var to = /** @type{number} */(e["toColIndex"]);
|
27845
|
+
_t._sortStates = [];
|
27846
|
+
_t._sortingSequence = ["a", "d"];
|
27799
27847
|
|
27800
|
-
|
27801
|
-
|
27802
|
-
};
|
27803
|
-
/** @protected
|
27804
|
-
* @ignore
|
27805
|
-
* @param {Object} e
|
27806
|
-
*/
|
27807
|
-
Plugin.prototype._onColumnRemoved = function (e) {
|
27808
|
-
if (this._isNotFirstHost(e)) {
|
27809
|
-
return;
|
27810
|
-
}
|
27811
|
-
if (!e["atTheMiddle"]) { return; }
|
27812
|
-
var colIndex = /** @type{number} */(e["colIndex"]);
|
27813
|
-
if(this._colData) {
|
27814
|
-
this._colData.splice(colIndex, 1);
|
27815
|
-
}
|
27816
|
-
if(this._dataMap) {
|
27817
|
-
this._dataMap.splice(colIndex, 1);
|
27848
|
+
if(options) {
|
27849
|
+
_t.config({ "sorting": options });
|
27818
27850
|
}
|
27819
27851
|
};
|
27852
|
+
es6_Ext.inherits(SortableTitlePlugin, event_EventDispatcher);
|
27820
27853
|
|
27821
|
-
|
27822
|
-
|
27823
|
-
* @ignore
|
27824
|
-
* @return {number}
|
27854
|
+
/**
|
27855
|
+
* @typedef {"a" | "ascending" | "d" | "descending" | "n" | null} SortableTitlePlugin~SortOrder
|
27825
27856
|
*/
|
27826
|
-
|
27827
|
-
|
27828
|
-
|
27829
|
-
}
|
27830
|
-
|
27831
|
-
* @
|
27832
|
-
* @param {string} pluginName
|
27833
|
-
* @return {*|null}
|
27857
|
+
|
27858
|
+
/** The sorting object which will be used for initialSort config.
|
27859
|
+
* @typedef {Object} SortableTitlePlugin~InitialSort
|
27860
|
+
* @property {number} colIndex Index of the column
|
27861
|
+
* @property {SortableTitlePlugin~SortOrder=} sortOrder=null Set to "d" for descending order and "a" for ascending order
|
27862
|
+
* @property {SortableTitlePlugin~SortOrder=} order Alias of sortOrder
|
27834
27863
|
*/
|
27835
|
-
|
27836
|
-
var host = this._host || this._hosts[0];
|
27837
|
-
return (host) ? host.getPlugin(pluginName) : null;
|
27838
|
-
};
|
27839
|
-
|
27840
|
-
/** @protected
|
27841
|
-
* @ignore
|
27842
|
-
* @param {number} scrollVal
|
27843
|
-
*/
|
27844
|
-
Plugin.prototype._scrollDown = function (scrollVal) {
|
27845
|
-
var host = this._host || this._hosts[0];
|
27846
|
-
host.scrollDown(scrollVal);
|
27847
|
-
};
|
27848
|
-
/** @protected
|
27849
|
-
* @ignore
|
27850
|
-
* @param {number} rowIndex
|
27851
|
-
*/
|
27852
|
-
Plugin.prototype._scrollToRow = function (rowIndex) {
|
27853
|
-
var host = this._host || this._hosts[0];
|
27854
|
-
host.scrollToRow(null, rowIndex);
|
27855
|
-
};
|
27856
|
-
/** @protected
|
27857
|
-
* @ignore
|
27858
|
-
* @param {number} scrollVal
|
27859
|
-
*/
|
27860
|
-
Plugin.prototype._scrollRight = function (scrollVal) {
|
27861
|
-
if(this._host) {
|
27862
|
-
this._host.scrollRight(scrollVal);
|
27863
|
-
} else if(this._hosts) {
|
27864
|
-
var len = this._hosts.length;
|
27865
|
-
for(var i = 0; i < len; ++i) {
|
27866
|
-
var host = this._hosts[i];
|
27867
|
-
host.scrollRight(scrollVal);
|
27868
|
-
}
|
27869
|
-
}
|
27870
|
-
};
|
27871
|
-
|
27872
|
-
//#endregion Protected Methods
|
27873
|
-
|
27874
|
-
//#region Protected Fields
|
27875
|
-
/** @protected
|
27876
|
-
* @ignore
|
27877
|
-
* @type {Core}
|
27878
|
-
*/
|
27879
|
-
Plugin.prototype._host = null;
|
27880
|
-
/** @protected
|
27881
|
-
* @ignore
|
27882
|
-
* @type {Array.<Core>}
|
27883
|
-
*/
|
27884
|
-
Plugin.prototype._hosts = null; // For a plug-in that support multi-table
|
27885
|
-
|
27886
|
-
/** @protected
|
27887
|
-
* @ignore
|
27888
|
-
* @type {Array.<string|null>}
|
27889
|
-
*/
|
27890
|
-
Plugin.prototype._dataMap = null;
|
27891
|
-
/** @protected
|
27892
|
-
* @ignore
|
27893
|
-
* @type {Array.<Object>}
|
27894
|
-
*/
|
27895
|
-
Plugin.prototype._colData = null;
|
27896
|
-
//#endregion Protected Fields
|
27897
|
-
|
27898
|
-
Plugin._proto = Plugin.prototype;
|
27899
|
-
|
27900
|
-
/* harmony default export */ const plugins_Plugin = (Plugin);
|
27901
|
-
|
27902
|
-
|
27903
|
-
;// CONCATENATED MODULE: ./src/js/grid/plugins/DragAndDropTitlePlugin.js
|
27904
|
-
/* eslint-disable */
|
27905
|
-
|
27906
|
-
|
27907
|
-
|
27908
|
-
|
27909
|
-
|
27910
|
-
/* eslint-enable */
|
27911
|
-
|
27912
|
-
/** Event
|
27913
|
-
* @event DragAndDropTitlePlugin#dragged
|
27914
|
-
* @type {MouseEvent}
|
27915
|
-
* @property {*} * Depends on the browser's mouse event arguments
|
27916
|
-
*/
|
27917
|
-
/** Event
|
27918
|
-
* @event DragAndDropTitlePlugin#columnMoved
|
27919
|
-
* @property {number} startColumnIndex
|
27920
|
-
* @property {number} destColumnIndex
|
27921
|
-
*/
|
27922
|
-
|
27923
|
-
/** @constructor
|
27924
|
-
* @extends {Plugin}
|
27925
|
-
*/
|
27926
|
-
var DragAndDropTitlePlugin = function () {
|
27927
|
-
var _t = this;
|
27928
|
-
|
27929
|
-
_t._onColumnAdded = _t._onColumnAdded.bind(_t);
|
27930
|
-
_t._onColumnMoved = _t._onColumnMoved.bind(_t);
|
27931
|
-
_t._onColumnRemoved = _t._onColumnRemoved.bind(_t);
|
27932
|
-
|
27933
|
-
_t._onMouseUp = _t._onMouseUp.bind(_t);
|
27934
|
-
_t._onMouseDown = _t._onMouseDown.bind(_t);
|
27935
|
-
|
27936
|
-
_t._onDrag = _t._onDrag.bind(_t);
|
27937
|
-
_t._onDragStart = _t._onDragStart.bind(_t);
|
27938
|
-
_t._onDragEnd = _t._onDragEnd.bind(_t);
|
27939
|
-
_t._onDragPulse = _t._onDragPulse.bind(_t);
|
27940
|
-
|
27941
|
-
_t._hosts = [];
|
27942
|
-
|
27943
|
-
_t._guideline = document.createElement("svg");
|
27944
|
-
_t._guideline.className = "tr-guideline";
|
27945
|
-
_t._dragbox = document.createElement("svg");
|
27946
|
-
_t._dragbox.className = "tr-dragbox";
|
27947
|
-
|
27948
|
-
_t._addEvent("dragged"); // drag
|
27949
|
-
_t._addEvent("dragStart");
|
27950
|
-
_t._addEvent("dragInterval");
|
27951
|
-
_t._addEvent("preColumnMoved");
|
27952
|
-
_t._addEvent("columnMoved");
|
27953
|
-
|
27954
|
-
};
|
27955
|
-
es6_Ext.inherits(DragAndDropTitlePlugin, plugins_Plugin);
|
27956
|
-
|
27957
|
-
|
27958
|
-
/** @private
|
27959
|
-
* @type {Core}
|
27960
|
-
*/
|
27961
|
-
DragAndDropTitlePlugin.prototype._clickedGrid;
|
27962
|
-
/** @private
|
27963
|
-
* @type {ILayoutGrid}
|
27964
|
-
*/
|
27965
|
-
DragAndDropTitlePlugin.prototype._clickedSection = null;
|
27966
|
-
/** @private
|
27967
|
-
* @type {number}
|
27968
|
-
*/
|
27969
|
-
DragAndDropTitlePlugin.prototype._clickedRow = -1;
|
27970
|
-
/** @private
|
27971
|
-
* @type {!Element}
|
27972
|
-
*/
|
27973
|
-
DragAndDropTitlePlugin.prototype._guideline;
|
27974
|
-
/** @private
|
27975
|
-
* @type {!Element}
|
27976
|
-
*/
|
27977
|
-
DragAndDropTitlePlugin.prototype._dragbox;
|
27978
|
-
/** @private
|
27979
|
-
* @type {number}
|
27980
|
-
*/
|
27981
|
-
DragAndDropTitlePlugin.prototype._timerId = 0;
|
27982
|
-
/** @private
|
27983
|
-
* @type {number}
|
27984
|
-
*/
|
27985
|
-
DragAndDropTitlePlugin.prototype._dragPulseId = 0;
|
27986
|
-
/** @private
|
27987
|
-
* @type {Object}
|
27988
|
-
*/
|
27989
|
-
DragAndDropTitlePlugin.prototype._pos = null; // Cache of current mouse position
|
27990
|
-
/** @private
|
27991
|
-
* @type {number}
|
27992
|
-
*/
|
27993
|
-
DragAndDropTitlePlugin.prototype._cacheLeft = 0;
|
27994
|
-
/** @private
|
27995
|
-
* @type {number}
|
27996
|
-
*/
|
27997
|
-
DragAndDropTitlePlugin.prototype._cacheWidth = 0;
|
27998
|
-
|
27999
|
-
/** @private
|
28000
|
-
* @type {number}
|
28001
|
-
*/
|
28002
|
-
DragAndDropTitlePlugin.prototype._startColumn = -1;
|
28003
|
-
/** @private
|
28004
|
-
* @type {number}
|
28005
|
-
*/
|
28006
|
-
DragAndDropTitlePlugin.prototype._endColumn = -1;
|
28007
|
-
/** @private
|
28008
|
-
* @type {number}
|
28009
|
-
*/
|
28010
|
-
DragAndDropTitlePlugin.prototype._destColumn = -1;
|
28011
|
-
/** @private
|
28012
|
-
* @type {number}
|
28013
|
-
*/
|
28014
|
-
DragAndDropTitlePlugin.prototype._leftMovableBorder = -1;
|
28015
|
-
/** @private
|
28016
|
-
* @type {number}
|
28017
|
-
*/
|
28018
|
-
DragAndDropTitlePlugin.prototype._rightMovableBorder = -1;
|
28019
|
-
/** @private
|
28020
|
-
* @type {boolean}
|
28021
|
-
*/
|
28022
|
-
DragAndDropTitlePlugin.prototype._isDragging = false;
|
28023
|
-
/** @private
|
28024
|
-
* @type {boolean}
|
28025
|
-
*/
|
28026
|
-
DragAndDropTitlePlugin.prototype._lockFrozen = false;
|
28027
|
-
/** @private
|
28028
|
-
* @type {boolean}
|
28029
|
-
*/
|
28030
|
-
DragAndDropTitlePlugin.prototype._disabled = false;
|
28031
|
-
/** @private
|
28032
|
-
* @type {boolean}
|
28033
|
-
*/
|
28034
|
-
DragAndDropTitlePlugin.prototype._noColumnMoving = false;
|
28035
|
-
/** @private
|
28036
|
-
* @type {boolean}
|
28037
|
-
*/
|
28038
|
-
DragAndDropTitlePlugin.prototype._noDragBox = false;
|
28039
|
-
|
28040
|
-
|
28041
|
-
/** @override */
|
28042
|
-
DragAndDropTitlePlugin.prototype.getName = function () {
|
28043
|
-
return "DragAndDropTitlePlugin"; // Read Only
|
28044
|
-
};
|
28045
|
-
/** @override */
|
28046
|
-
DragAndDropTitlePlugin.prototype.initialize = function (host) {
|
28047
|
-
if(this._hosts.indexOf(host) >= 0) { return; }
|
28048
|
-
|
28049
|
-
this._hosts.push(host);
|
28050
|
-
host.listen("mousedown", this._onMouseDown);
|
28051
|
-
host.listen("columnAdded", this._onColumnAdded);
|
28052
|
-
host.listen("columnMoved", this._onColumnMoved);
|
28053
|
-
host.listen("columnRemoved", this._onColumnRemoved);
|
28054
|
-
|
28055
|
-
host.listen("dragstart", util._preventDefault);
|
28056
|
-
};
|
28057
|
-
|
28058
|
-
/** @override */
|
28059
|
-
DragAndDropTitlePlugin.prototype.unload = function (host) {
|
28060
|
-
var at = this._hosts.indexOf(host);
|
28061
|
-
if(at < 0) { return; }
|
28062
|
-
|
28063
|
-
this._hosts.splice(at, 1);
|
28064
|
-
host.unlisten("mousedown", this._onMouseDown);
|
28065
|
-
host.unlisten("columnAdded", this._onColumnAdded);
|
28066
|
-
host.unlisten("columnMoved", this._onColumnMoved);
|
28067
|
-
host.unlisten("columnRemoved", this._onColumnRemoved);
|
28068
|
-
};
|
28069
|
-
|
28070
|
-
/** Specify column to be processed by this plugin
|
28071
|
-
* @public
|
28072
|
-
* @return {null}
|
28073
|
-
*/
|
28074
|
-
DragAndDropTitlePlugin.prototype.getMarker = function () {
|
28075
|
-
return null;
|
28076
|
-
};
|
28077
|
-
|
28078
|
-
/**
|
28079
|
-
* Lock moving of frozen column. If true is spsecified, dragging is disabled for frozen column.
|
28080
|
-
* @public
|
28081
|
-
* @param {boolean} lock
|
28082
|
-
*/
|
28083
|
-
DragAndDropTitlePlugin.prototype.lockFrozenColumn = function(lock) {
|
28084
|
-
this._lockFrozen = lock;
|
28085
|
-
};
|
28086
|
-
|
28087
|
-
/** Disable this plugin entirely
|
28088
|
-
* @public
|
28089
|
-
* @param {boolean=} opt_disabled
|
28090
|
-
*/
|
28091
|
-
DragAndDropTitlePlugin.prototype.disable = function(opt_disabled) {
|
28092
|
-
this._disabled = opt_disabled !== false;
|
28093
|
-
};
|
28094
|
-
/** Disable column moving. Only cursor is showing and events are fired. No real column moving.
|
28095
|
-
* @public
|
28096
|
-
* @param {boolean=} opt_disabled
|
28097
|
-
*/
|
28098
|
-
DragAndDropTitlePlugin.prototype.disableMoving = function(opt_disabled) {
|
28099
|
-
this._noColumnMoving = opt_disabled !== false;
|
28100
|
-
};
|
28101
|
-
/** Disable column moving. Only cursor is showing and events are fired. No real column moving.
|
28102
|
-
* @public
|
28103
|
-
* @param {boolean=} opt_disabled
|
28104
|
-
*/
|
28105
|
-
DragAndDropTitlePlugin.prototype.disableDragBox = function(opt_disabled) {
|
28106
|
-
this._noDragBox = opt_disabled !== false;
|
28107
|
-
};
|
28108
|
-
|
28109
|
-
/** @private
|
28110
|
-
* @param {number} colIndex
|
28111
|
-
* @return {boolean}
|
28112
|
-
*/
|
28113
|
-
DragAndDropTitlePlugin.prototype._isAllowed = function(colIndex) {
|
28114
|
-
var host = this._clickedGrid || this._hosts[0];
|
28115
|
-
if (host) {
|
28116
|
-
var stationaryIndex = host.getStationaryColumnIndex();
|
28117
|
-
if (stationaryIndex < 0) {
|
28118
|
-
return true;
|
28119
|
-
}
|
28120
|
-
if (colIndex <= stationaryIndex) {
|
28121
|
-
return false;
|
28122
|
-
}
|
28123
|
-
}
|
28124
|
-
return true;
|
28125
|
-
};
|
28126
|
-
/** @private
|
28127
|
-
* @param {Event} e
|
28128
|
-
*/
|
28129
|
-
DragAndDropTitlePlugin.prototype._onMouseDown = function (e) {
|
28130
|
-
if(this._disabled) {
|
28131
|
-
return;
|
28132
|
-
}
|
28133
|
-
if(e.shiftKey || e.ctrlKey || e.altKey) {
|
28134
|
-
return; // Ignore mousedown event, if modifier key is detected
|
28135
|
-
}
|
28136
|
-
if(e.button) {
|
28137
|
-
return; // We don't allow drag with middle click (button == 1), or right click (button == 2)
|
28138
|
-
}
|
28139
|
-
if(this._timerId) {
|
28140
|
-
return; // Drag timer is already start
|
28141
|
-
}
|
28142
|
-
|
28143
|
-
var host = this.getRelativeGrid(e);
|
28144
|
-
if(!host) {
|
28145
|
-
return; // Given event should be within grid element
|
28146
|
-
}
|
28147
|
-
|
28148
|
-
this._pos = host.getRelativePosition(e);
|
28149
|
-
if (this._pos["hit"] === false) {
|
28150
|
-
return; // Only start dragging when mouse is down on the grid
|
28151
|
-
}
|
28152
|
-
|
28153
|
-
var section = /** @type{ILayoutGrid} */(this._pos["section"]);
|
28154
|
-
if(!section) {
|
28155
|
-
return; // The section that is not in the target section list cannot be dragged
|
28156
|
-
} else if(this._pos["sectionType"] !== "title") {
|
28157
|
-
return; // Sections other than title section cannot be dragged by default
|
28158
|
-
}
|
28159
|
-
|
28160
|
-
var colIndex = this._pos["colIndex"];
|
28161
|
-
if(!this._isAllowed(colIndex)) {
|
28162
|
-
return; // The column cannot be dragged
|
28163
|
-
}
|
28164
|
-
if(this._lockFrozen && host.isPinnedColumn(colIndex)) {
|
28165
|
-
return; // If the lock frag is on, frozen columns cannot be dragged
|
28166
|
-
}
|
28167
|
-
|
28168
|
-
var rowIndex = this._pos["rowIndex"]; // rowIndex may not exist
|
28169
|
-
var movableBorder = this._findMoveableBorder(colIndex, rowIndex - 1, section);
|
28170
|
-
var movingColumns = this._getSpan(colIndex, rowIndex, section);
|
28171
|
-
|
28172
|
-
this._clickedGrid = host;
|
28173
|
-
this._clickedSection = section;
|
28174
|
-
this._clickedRow = rowIndex;
|
28175
|
-
|
28176
|
-
this._startColumn = movingColumns["left"];
|
28177
|
-
this._endColumn = movingColumns["right"];
|
28178
|
-
this._leftMovableBorder = movableBorder["left"];
|
28179
|
-
this._rightMovableBorder = movableBorder["right"];
|
28180
|
-
this._destColumn = this._startColumn;
|
28181
|
-
|
28182
|
-
this._timerId = setTimeout(this._onDragStart, 300);
|
28183
|
-
window.addEventListener("mouseup", this._onMouseUp, false);
|
28184
|
-
};
|
28185
|
-
/** @private
|
28186
|
-
* @param {Object} e
|
28187
|
-
*/
|
28188
|
-
DragAndDropTitlePlugin.prototype._onMouseUp = function (e) {
|
28189
|
-
if(this._timerId) {
|
28190
|
-
window.clearTimeout(this._timerId);
|
28191
|
-
window.removeEventListener("mouseup", this._onMouseUp, false);
|
28192
|
-
this._timerId = 0;
|
28193
|
-
this._clearCache();
|
28194
|
-
}
|
28195
|
-
};
|
28196
|
-
|
28197
|
-
/** @private
|
28198
|
-
*/
|
28199
|
-
DragAndDropTitlePlugin.prototype._onDragStart = function () {
|
28200
|
-
if(this._disabled || this._isDragging) { return; }
|
28201
|
-
|
28202
|
-
if (this._hasListener("dragStart")) {
|
28203
|
-
this._dispatch("dragStart", /** @type{!Object} */(this._pos));
|
28204
|
-
}
|
28205
|
-
|
28206
|
-
if (this._pos["cancel"]) {
|
28207
|
-
return;
|
28208
|
-
}
|
28209
|
-
|
28210
|
-
this._timerId = 0;
|
28211
|
-
window.removeEventListener("mouseup", this._onMouseUp, false);
|
28212
|
-
|
28213
|
-
if(!this._clickedGrid) {
|
28214
|
-
return;
|
28215
|
-
}
|
28216
|
-
|
28217
|
-
this._isDragging = true;
|
28218
|
-
document.body.classList.add("tr-dragging"); // Prevent text selection
|
28219
|
-
// document.body.classList.add("tr-move-cursor");
|
28220
|
-
|
28221
|
-
window.addEventListener("mousemove", this._onDrag, false);
|
28222
|
-
window.addEventListener("mouseup", this._onDragEnd, true);
|
28223
|
-
|
28224
|
-
var host = this._clickedGrid;
|
28225
|
-
var height = host.getHeight();
|
28226
|
-
var sectionBound = this._clickedSection.getBoundingClientRect();
|
28227
|
-
var clickedCellBound = this._clickedSection.getCell(this._startColumn, this._clickedRow).getBoundingClientRect();
|
28228
|
-
|
28229
|
-
var gridElem = host.getElement();
|
28230
|
-
this._guideline.style.top = (clickedCellBound.top - sectionBound.top) + "px";
|
28231
|
-
this._guideline.style.height = (height - 1) + "px";
|
28232
|
-
this._dragbox.style.height = (height - 33) + "px"; // WARNING: Height could be long
|
28233
|
-
this._dragbox.style.width = this._clickedSection.getColumnWidth(this._startColumn) + "px";
|
28234
|
-
|
28235
|
-
// TODO: guideline and drag box should be outside of grid area
|
28236
|
-
gridElem.appendChild(this._guideline);
|
28237
|
-
|
28238
|
-
this._dimCol(true);
|
28239
|
-
this._renderGuideline();
|
28240
|
-
|
28241
|
-
// For step scrolling // TODO: Merge this logic with DraggableContentPlugin
|
28242
|
-
this._scrollStep = Math.floor(host.getScrollWidth() / 25); // Update the scrollbar first
|
28243
|
-
if(this._scrollStep < 40) {
|
28244
|
-
this._scrollStep = 40;
|
28245
|
-
} else if(this._scrollStep > 400) {
|
28246
|
-
this._scrollStep = 400;
|
28247
|
-
}
|
28248
|
-
var scrollbar = host.getHScrollbar();
|
28249
|
-
this._cacheLeft = scrollbar.getLeft() + 20;
|
28250
|
-
this._cacheWidth = scrollbar.getLeft() + scrollbar.getWidth() - 20;
|
28251
|
-
|
28252
|
-
this._dragPulseId = window.setInterval(this._onDragPulse, 150); // Start pulse
|
28253
|
-
};
|
28254
|
-
/** @private
|
28255
|
-
* @param {Event} e
|
28256
|
-
*/
|
28257
|
-
DragAndDropTitlePlugin.prototype._onDrag = function (e) {
|
28258
|
-
if(!this._isDragging) { return; }
|
28259
|
-
|
28260
|
-
util._preventDefault(e);
|
28261
|
-
this._pos = this._clickedGrid.getRelativePosition(e); // Relative to the clicked grid
|
28262
|
-
|
28263
|
-
var host = this.getRelativeGrid(e);
|
28264
|
-
if (!host || host !== this._clickedGrid) { return; }
|
28265
|
-
|
28266
|
-
var colIndex = this._pos["colIndex"];
|
28267
|
-
if ((colIndex >= this._leftMovableBorder) &&
|
28268
|
-
(colIndex <= this._rightMovableBorder) &&
|
28269
|
-
this._isAllowed(colIndex) &&
|
28270
|
-
!(this._lockFrozen && host.isPinnedColumn(colIndex))) {
|
28271
|
-
this._renderGuideline();
|
28272
|
-
this._dispatch("dragged", /** @type{!Object} */(e));
|
28273
|
-
}
|
28274
|
-
this._renderDragBox(e);
|
28275
|
-
};
|
28276
|
-
/** @private
|
28277
|
-
* @param {Event} e
|
28278
|
-
*/
|
28279
|
-
DragAndDropTitlePlugin.prototype._onDragEnd = function (e) {
|
28280
|
-
if(!this._isDragging) {
|
28281
|
-
return;
|
28282
|
-
}
|
28283
|
-
|
28284
|
-
this._isDragging = false;
|
28285
|
-
document.body.classList.remove("tr-dragging");
|
28286
|
-
// document.body.classList.remove("tr-move-cursor");
|
28287
|
-
this._dimCol(false);
|
28288
|
-
|
28289
|
-
var pn = this._guideline.parentNode;
|
28290
|
-
if(pn) {
|
28291
|
-
pn.removeChild(this._guideline);
|
28292
|
-
}
|
28293
|
-
|
28294
|
-
pn = this._dragbox.parentNode;
|
28295
|
-
if(pn) {
|
28296
|
-
pn.removeChild(this._dragbox);
|
28297
|
-
}
|
28298
|
-
|
28299
|
-
window.removeEventListener("mousemove", this._onDrag, false);
|
28300
|
-
window.removeEventListener("mouseup", this._onDragEnd, true);
|
28301
|
-
|
28302
|
-
if(this._dragPulseId) {
|
28303
|
-
window.clearInterval(this._dragPulseId);
|
28304
|
-
this._dragPulseId = 0;
|
28305
|
-
}
|
28306
|
-
this._pos = null;
|
28307
|
-
|
28308
|
-
util._preventDefault(e);
|
28309
|
-
|
28310
|
-
//When move to the right, the first position is the current one.
|
28311
|
-
if (this._destColumn > this._startColumn) {
|
28312
|
-
--this._destColumn;
|
28313
|
-
}
|
28314
|
-
//Cancel moving if the destination column is the current column or not allowed column
|
28315
|
-
if ((!this._destColumn && this._destColumn !== 0) || // undefined, NaN, null
|
28316
|
-
this._destColumn < 0 ||
|
28317
|
-
!this._isAllowed(this._destColumn) ||
|
28318
|
-
(this._destColumn >= this._startColumn && this._destColumn <= this._endColumn)) {
|
28319
|
-
this._clearCache();
|
28320
|
-
return;
|
28321
|
-
}
|
28322
|
-
|
28323
|
-
var arg = {
|
28324
|
-
"startColumnIndex": this._startColumn,
|
28325
|
-
"destColumnIndex": this._destColumn
|
28326
|
-
};
|
28327
|
-
|
28328
|
-
if (this._hasListener("preColumnMoved")) {
|
28329
|
-
this._dispatch("preColumnMoved", arg);
|
28330
|
-
}
|
28331
|
-
|
28332
|
-
if (arg["cancel"]) {
|
28333
|
-
return;
|
28334
|
-
}
|
28335
|
-
|
28336
|
-
if (!this._noColumnMoving) {
|
28337
|
-
var shiftStart = -1;
|
28338
|
-
var shiftEnd = -1;
|
28339
|
-
var moveSize = -1;
|
28340
|
-
if (this._startColumn > this._destColumn) { //Move backward
|
28341
|
-
shiftStart = this._destColumn;
|
28342
|
-
shiftEnd = this._startColumn - 1;
|
28343
|
-
moveSize = -1 * (this._startColumn - this._destColumn); //Move to the left
|
28344
|
-
} else
|
28345
|
-
if (this._startColumn < this._destColumn) { //Move foward
|
28346
|
-
shiftStart = this._endColumn + 1;
|
28347
|
-
shiftEnd = this._destColumn;
|
28348
|
-
moveSize = ((shiftEnd - shiftStart) + 1); //Move to the right
|
28349
|
-
}
|
28350
|
-
|
28351
|
-
//Perform moving all columns in the range
|
28352
|
-
for(var j = this._hosts.length; --j >= 0;) {
|
28353
|
-
var host = this._hosts[j];
|
28354
|
-
var i;
|
28355
|
-
if (moveSize > 0) { //Move forward
|
28356
|
-
for (i = this._startColumn; i <= this._endColumn; i++) {
|
28357
|
-
host.moveColumn(this._startColumn, this._destColumn);
|
28358
|
-
}
|
28359
|
-
} else { //Move backward
|
28360
|
-
for (i = this._startColumn; i <= this._endColumn; i++) {
|
28361
|
-
host.moveColumn(this._startColumn + (i - this._startColumn), this._destColumn + (i - this._startColumn));
|
28362
|
-
}
|
28363
|
-
}
|
28364
|
-
}
|
28365
|
-
}
|
28366
|
-
|
28367
|
-
if (this._hasListener("columnMoved")) {
|
28368
|
-
this._dispatch("columnMoved", {
|
28369
|
-
"startColumnIndex": this._startColumn,
|
28370
|
-
"endColumnIndex": this._endColumn,
|
28371
|
-
"destColumnIndex": this._destColumn,
|
28372
|
-
"clickedRow": this._clickedRow
|
28373
|
-
});
|
28374
|
-
}
|
28375
|
-
this._clearCache();
|
28376
|
-
};
|
28377
|
-
|
28378
|
-
/** @private
|
28379
|
-
*/
|
28380
|
-
DragAndDropTitlePlugin.prototype._onDragPulse = function() {
|
28381
|
-
if(!this._isDragging || !this._pos) { return; }
|
28382
|
-
|
28383
|
-
this._dispatch("dragInterval", /** @type{!Object} */(this._pos));
|
28384
|
-
|
28385
|
-
var host = this._clickedGrid;
|
28386
|
-
if(!host || !host.getHScrollbar().isActive()) { return; }
|
28387
|
-
|
28388
|
-
var x = this._pos["x"];
|
28389
|
-
var scrollVal = 0;
|
28390
|
-
if(x < this._cacheLeft) {
|
28391
|
-
scrollVal = -Math.floor(this._scrollStep * (0.8 + Math.random()));
|
28392
|
-
|
28393
|
-
} else if(x > this._cacheWidth) {
|
28394
|
-
scrollVal = Math.floor(this._scrollStep * (0.8 + Math.random()));
|
28395
|
-
}
|
28396
|
-
|
28397
|
-
this._scrollRight(scrollVal);
|
28398
|
-
};
|
28399
|
-
/** @private
|
28400
|
-
*/
|
28401
|
-
DragAndDropTitlePlugin.prototype._clearCache = function() {
|
28402
|
-
this._startColumn = this._endColumn = this._destColumn = -1;
|
28403
|
-
|
28404
|
-
this._leftMovableBorder = this._rightMovableBorder = -1;
|
28405
|
-
|
28406
|
-
this._clickedRow = -1;
|
28407
|
-
this._clickedSection = this._clickedGrid = null;
|
28408
|
-
};
|
28409
|
-
|
28410
|
-
/** @private
|
28411
|
-
* @param {number} colIndex
|
28412
|
-
* @param {number} row
|
28413
|
-
* @param {ILayoutGrid} section
|
28414
|
-
* @return {!Object}
|
28415
|
-
*/
|
28416
|
-
DragAndDropTitlePlugin.prototype._getSpan = function(colIndex, row, section) {
|
28417
|
-
var cellSpan = section.getCellColSpan(colIndex, row);
|
28418
|
-
|
28419
|
-
if (cellSpan <= 0) { // The specified cell is being occupied
|
28420
|
-
colIndex += cellSpan; // Convert the given negative index to the spanning cell
|
28421
|
-
cellSpan = section.getCellColSpan(colIndex, row);
|
28422
|
-
}
|
28423
|
-
|
28424
|
-
return { "left": colIndex, "right": (colIndex + cellSpan - 1) };
|
28425
|
-
};
|
28426
|
-
/** @private
|
28427
|
-
* @param {number} col
|
28428
|
-
* @param {number} row
|
28429
|
-
* @param {ILayoutGrid} section
|
28430
|
-
* @return {!Object}
|
28431
|
-
*/
|
28432
|
-
DragAndDropTitlePlugin.prototype._findMoveableBorder = function(col, row, section) {
|
28433
|
-
if (row < 0 || (!row && row !== 0)) { // Guaranteed to get out of infinite loop by checking undefined, NaN, null
|
28434
|
-
return { "left": 0, "right": (section.getColumnCount() - 1) };
|
28435
|
-
}
|
28436
|
-
var span = this._getSpan(col, row, section);
|
28437
|
-
if (span["right"] >= span["left"]) {
|
28438
|
-
return span;
|
28439
|
-
} else {
|
28440
|
-
return this._findMoveableBorder(col, row - 1, section);
|
28441
|
-
}
|
28442
|
-
};
|
28443
|
-
/**
|
28444
|
-
* @private
|
28445
|
-
*/
|
28446
|
-
DragAndDropTitlePlugin.prototype._renderGuideline = function() {
|
28447
|
-
var colIndex = this._pos["colIndex"];
|
28448
|
-
if(colIndex == null || colIndex < 0) { // undefined, null or negative number
|
28449
|
-
return;
|
28450
|
-
}
|
28451
|
-
|
28452
|
-
var currentSpan = this._getSpan(colIndex, this._clickedRow, this._clickedSection);
|
28453
|
-
var colStart = currentSpan["left"]; // This can be different from colIndex
|
28454
|
-
var colEnd = currentSpan["right"];
|
28455
|
-
var colLeft = this._clickedGrid.getColumnLeft(colStart);
|
28456
|
-
var colWidth = 0;
|
28457
|
-
for(var i = colStart; i <= colEnd; ++i) {
|
28458
|
-
colWidth += this._clickedGrid.getColumnWidth(i);
|
28459
|
-
}
|
28460
|
-
|
28461
|
-
var rightHand = this._pos["x"] > colLeft + colWidth / 2;
|
28462
|
-
var destColumn = (rightHand) ? colEnd + 1 : colStart;
|
28463
|
-
|
28464
|
-
colLeft = this._clickedGrid.getColumnLeft(this._destColumn);
|
28465
|
-
// If destination exceeds the specified bounds
|
28466
|
-
if (destColumn < this._leftMovableBorder) {
|
28467
|
-
destColumn = this._leftMovableBorder;
|
28468
|
-
} else if (destColumn > this._rightMovableBorder) {
|
28469
|
-
destColumn = this._rightMovableBorder + 1;
|
28470
|
-
if(rightHand) {
|
28471
|
-
colLeft -= 4; // Shift guideline to the left if this is the rightmost column
|
28472
|
-
}
|
28473
|
-
}
|
28474
|
-
|
28475
|
-
this._destColumn = destColumn;
|
28476
|
-
this._guideline.style.left = colLeft + "px";
|
28477
|
-
};
|
28478
|
-
/** @private
|
28479
|
-
* @param {!Element|Event|MouseEvent} e
|
28480
|
-
*/
|
28481
|
-
DragAndDropTitlePlugin.prototype._renderDragBox = function(e) {
|
28482
|
-
if(this._noDragBox) {
|
28483
|
-
return;
|
28484
|
-
}
|
28485
|
-
|
28486
|
-
var gridElem = this._clickedGrid.getElement();
|
28487
|
-
var pn = this._dragbox.parentNode;
|
28488
|
-
if(!pn) {
|
28489
|
-
gridElem.appendChild(this._dragbox);
|
28490
|
-
}
|
28491
|
-
|
28492
|
-
var gridRect = gridElem.getBoundingClientRect();
|
28493
|
-
var zoomFactor = this._clickedGrid["zoomFactor"]; // TODO: Remove zoom factor
|
28494
|
-
var contentWidth = gridRect.width;
|
28495
|
-
|
28496
|
-
var x = e.clientX - gridRect.left;
|
28497
|
-
var y = ((e.pageY - gridRect.top) / zoomFactor) - window.scrollY;
|
28498
|
-
var midFactor = parseFloat((x / contentWidth).toFixed(2));
|
28499
|
-
var dragboxLeft = (gridRect.width * midFactor) / zoomFactor - this._dragbox.offsetWidth * midFactor;
|
28500
|
-
|
28501
|
-
this._dragbox.style.left = dragboxLeft + "px";
|
28502
|
-
this._dragbox.style.top = (y + 10) + "px";
|
28503
|
-
};
|
28504
|
-
|
28505
|
-
/**
|
28506
|
-
* @private
|
28507
|
-
* @param {boolean} inOut
|
28508
|
-
*/
|
28509
|
-
DragAndDropTitlePlugin.prototype._dimCol = function(inOut) {
|
28510
|
-
for (var i = this._startColumn; i <= this._endColumn; i++) {
|
28511
|
-
this._clickedGrid.enableColumnClass(i, "drag-fadeout", inOut);
|
28512
|
-
}
|
28513
|
-
};
|
28514
|
-
|
28515
|
-
DragAndDropTitlePlugin._proto = DragAndDropTitlePlugin.prototype;
|
28516
|
-
|
28517
|
-
/* harmony default export */ const plugins_DragAndDropTitlePlugin = (DragAndDropTitlePlugin);
|
28518
|
-
|
28519
|
-
|
28520
|
-
;// CONCATENATED MODULE: ./src/js/grid/plugins/SortableTitlePlugin.js
|
28521
|
-
/* eslint-disable */
|
28522
|
-
|
28523
|
-
|
28524
|
-
|
28525
|
-
|
28526
|
-
|
28527
|
-
|
28528
|
-
/* eslint-enable */
|
28529
|
-
|
28530
|
-
/** Fired when user click and before the sorting operation.
|
28531
|
-
* @event SortableTitlePlugin#preClicked
|
28532
|
-
* @property {number} colIndex
|
28533
|
-
* @property {Element} target Element being clicked
|
28534
|
-
* @example
|
28535
|
-
* function onPreClicked(e) {
|
28536
|
-
* e.cancel = true; // Cancel sorting operation
|
28537
|
-
* }
|
28538
|
-
*/
|
28539
|
-
|
28540
|
-
/** Fired when user click and after the sorting operation
|
28541
|
-
* @event SortableTitlePlugin#clicked
|
28542
|
-
* @property {number} colIndex
|
28543
|
-
* @property {string} sortOrder "a" for "ascending, "d" for descending, and "n" for none
|
28544
|
-
* @property {string} dataColumnName Field that is used for sorting
|
28545
|
-
*/
|
28546
|
-
|
28547
|
-
/** Fired just before sorting data. This allows additional modification before the actual sorting
|
28548
|
-
* @event SortableTitlePlugin#preDataSorting
|
28549
|
-
* @property {boolean=} isUserAction This has true value, if event initiate from clicking title/header section
|
28550
|
-
*/
|
28551
|
-
|
28552
|
-
/** Fired once column is sorted and before {@link SortableTitlePlugin#clicked}
|
28553
|
-
* @event SortableTitlePlugin#columnSorted
|
28554
|
-
* @property {number} colIndex
|
28555
|
-
* @property {string} sortOrder "a" for "ascending, "d" for descending, and "n" for none
|
28556
|
-
* @property {string} sortedField Field that is used for sorting
|
28557
|
-
* @property {Array.<number>} colIndices An array of colIndex
|
28558
|
-
* @property {Array.<string>} sortOrders An array of sortOrder
|
28559
|
-
* @property {Array.<string>} sortedFields An array of sortedField
|
28560
|
-
*/
|
28561
|
-
|
28562
|
-
/** @constructor
|
28563
|
-
* @extends {Plugin}
|
28564
|
-
* @param {SortableTitlePlugin.Options=} options
|
28565
|
-
*/
|
28566
|
-
var SortableTitlePlugin = function (options) { // TODO: Extract SortableTitlePlugin to grid extension.
|
28567
|
-
var _t = this;
|
28568
|
-
_t._onSectionAdded = _t._onSectionAdded.bind(_t);
|
28569
|
-
_t._onMouseDown = _t._onMouseDown.bind(_t);
|
28570
|
-
|
28571
|
-
_t._onUIUpdated = _t._onUIUpdated.bind(_t);
|
28572
|
-
|
28573
|
-
_t._onColumnAdded = _t._onColumnAdded.bind(_t);
|
28574
|
-
_t._onColumnRemoved = _t._onColumnRemoved.bind(_t);
|
28575
|
-
_t._onItemSortingClicked = _t._onItemSortingClicked.bind(_t);
|
28576
|
-
_t.refresh = _t.refresh.bind(_t);
|
28577
|
-
|
28578
|
-
_t._hosts = [];
|
28579
|
-
_t._sortLogic = {};
|
28580
|
-
|
28581
|
-
_t._addEvents(
|
28582
|
-
"preClicked"
|
28583
|
-
, "clicked"
|
28584
|
-
, "preDataSorting"
|
28585
|
-
, "columnSorted"
|
28586
|
-
);
|
28587
|
-
|
28588
|
-
_t._sortStates = [];
|
28589
|
-
_t._sortingSequence = ["a", "d"];
|
28590
|
-
|
28591
|
-
if(options) {
|
28592
|
-
_t.config({ "sorting": options });
|
28593
|
-
}
|
28594
|
-
};
|
28595
|
-
es6_Ext.inherits(SortableTitlePlugin, plugins_Plugin);
|
28596
|
-
|
28597
|
-
/**
|
28598
|
-
* @typedef {"a" | "ascending" | "d" | "descending" | "n" | null} SortableTitlePlugin~SortOrder
|
28599
|
-
*/
|
28600
|
-
|
28601
|
-
/** The sorting object which will be used for initialSort config.
|
28602
|
-
* @typedef {Object} SortableTitlePlugin~InitialSort
|
28603
|
-
* @property {number} colIndex Index of the column
|
28604
|
-
* @property {SortableTitlePlugin~SortOrder=} sortOrder=null Set to "d" for descending order and "a" for ascending order
|
28605
|
-
* @property {SortableTitlePlugin~SortOrder=} order Alias of sortOrder
|
28606
|
-
*/
|
28607
|
-
SortableTitlePlugin.InitialSort;
|
27864
|
+
SortableTitlePlugin.InitialSort;
|
28608
27865
|
|
28609
27866
|
/** The sorting properties for column option.
|
28610
27867
|
* @typedef {Object} SortableTitlePlugin~ColumnOptions
|
@@ -28638,6 +27895,12 @@ SortableTitlePlugin.ColumnOptions;
|
|
28638
27895
|
*/
|
28639
27896
|
SortableTitlePlugin.Options;
|
28640
27897
|
|
27898
|
+
|
27899
|
+
/** @type {Array.<Core>}
|
27900
|
+
* @private
|
27901
|
+
*/
|
27902
|
+
SortableTitlePlugin.prototype._hosts = null; // For a plug-in that support multi-table
|
27903
|
+
|
28641
27904
|
/** Order of item indicates sort priorities used in DataView. <br>
|
28642
27905
|
* Each state contains column name{string}, sort order {string}, and rendering cell {ElementWrapper}
|
28643
27906
|
* @private
|
@@ -28742,13 +28005,17 @@ var CODE_DOWN = "\u25BC";
|
|
28742
28005
|
*/
|
28743
28006
|
var CODE_DIAMOND = "\u25CA";
|
28744
28007
|
|
28745
|
-
/**
|
28008
|
+
/** The name must be readonly and unique among all other plugins
|
28009
|
+
* @public
|
28010
|
+
* @return {string}
|
28011
|
+
*/
|
28746
28012
|
SortableTitlePlugin.prototype.getName = function () {
|
28747
28013
|
return "SortableTitlePlugin"; // Read Only
|
28748
28014
|
};
|
28749
28015
|
|
28750
|
-
/**
|
28751
|
-
* @
|
28016
|
+
/** @public
|
28017
|
+
* @param {!Core} host
|
28018
|
+
* @param {Object=} options
|
28752
28019
|
* @description Suppress google compiler for argument options because Internal Plugin doesn't support.
|
28753
28020
|
* @suppress {checkTypes}
|
28754
28021
|
*/
|
@@ -28767,7 +28034,10 @@ SortableTitlePlugin.prototype.initialize = function (host, options) {
|
|
28767
28034
|
this.config(options);
|
28768
28035
|
};
|
28769
28036
|
|
28770
|
-
/**
|
28037
|
+
/**For disposing any resource
|
28038
|
+
* @public
|
28039
|
+
* @param {!Core} host
|
28040
|
+
*/
|
28771
28041
|
SortableTitlePlugin.prototype.unload = function (host) {
|
28772
28042
|
var at = this._hosts.indexOf(host);
|
28773
28043
|
if (at < 0) { return; }
|
@@ -29158,31 +28428,18 @@ SortableTitlePlugin.prototype.getSortOrder = function (colIndex) {
|
|
29158
28428
|
* @return {number} Return negative value if there is no sorted column
|
29159
28429
|
*/
|
29160
28430
|
SortableTitlePlugin.prototype.getSortedColumnIndex = function (priority) {
|
29161
|
-
|
29162
|
-
if (state) {
|
29163
|
-
var host = this._hosts[0];
|
29164
|
-
var colCount = host ? host.getColumnCount() : 0;
|
29165
|
-
for (var c = 0; c < colCount; ++c) {
|
29166
|
-
var sortOptions = this._getSortOptions(c);
|
29167
|
-
if (sortOptions === state) {
|
29168
|
-
return c;
|
29169
|
-
}
|
29170
|
-
}
|
29171
|
-
}
|
29172
|
-
return -1;
|
28431
|
+
return this._getColumnIndexByOptions(this._sortStates[priority || 0]);
|
29173
28432
|
};
|
29174
|
-
/**
|
28433
|
+
/** 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
|
28434
|
+
* @public
|
29175
28435
|
* @param {number} colIndex
|
29176
|
-
* @return {number}
|
28436
|
+
* @return {number}
|
29177
28437
|
*/
|
29178
28438
|
SortableTitlePlugin.prototype.getSortPriority = function (colIndex) {
|
29179
|
-
var
|
29180
|
-
|
29181
|
-
|
29182
|
-
|
29183
|
-
if (this._sortStates[i] === sortOptions) {
|
29184
|
-
return i;
|
29185
|
-
}
|
28439
|
+
var len = this._sortStates.length;
|
28440
|
+
for (var i = 0; i < len; ++i) {
|
28441
|
+
if (this._sortStates[i] === this._getSortOptions(colIndex)) {
|
28442
|
+
return i;
|
29186
28443
|
}
|
29187
28444
|
}
|
29188
28445
|
return -1;
|
@@ -29195,7 +28452,7 @@ SortableTitlePlugin.prototype.isColumnSorted = function (colIndex) {
|
|
29195
28452
|
return this.getSortPriority(colIndex) >= 0;
|
29196
28453
|
};
|
29197
28454
|
/** @public
|
29198
|
-
* @return {Array.<Object>
|
28455
|
+
* @return {Array.<Object>} Array of object with "colIndex" and "sortOrder"
|
29199
28456
|
*/
|
29200
28457
|
SortableTitlePlugin.prototype.getSortedColumns = function () {
|
29201
28458
|
var len = this._sortStates.length;
|
@@ -29204,28 +28461,33 @@ SortableTitlePlugin.prototype.getSortedColumns = function () {
|
|
29204
28461
|
var arr = new Array(len);
|
29205
28462
|
for (var i = 0; i < len; ++i) {
|
29206
28463
|
var colIndex = this.getSortedColumnIndex(i);
|
28464
|
+
var state = this._sortStates[i];
|
29207
28465
|
arr[i] = {
|
29208
28466
|
"colIndex": colIndex,
|
29209
|
-
"
|
28467
|
+
"field": state["field"] || "",
|
28468
|
+
"sortOrder": state["sortOrder"] || "n"
|
29210
28469
|
};
|
29211
28470
|
}
|
29212
28471
|
return arr;
|
29213
28472
|
};
|
28473
|
+
/** @public
|
28474
|
+
* @return {boolean}
|
28475
|
+
*/
|
28476
|
+
SortableTitlePlugin.prototype.isSorting = function () {
|
28477
|
+
return this._sortStates.length ? true : false;
|
28478
|
+
};
|
29214
28479
|
|
29215
28480
|
/** @public
|
29216
|
-
* @param {number}
|
28481
|
+
* @param {number|string} colRef Column index or field
|
29217
28482
|
* @param {string=} sortOrder "a" for ascending, "d" for descending, and "n" for no sorting
|
29218
28483
|
* @param {Object=} opt_arg Event argument to be sent with preDataSorting event
|
29219
28484
|
* @fires SortableTitlePlugin#preDataSorting
|
29220
28485
|
* @fires SortableTitlePlugin#columnSorted
|
29221
28486
|
*/
|
29222
|
-
SortableTitlePlugin.prototype.sortColumn = function (
|
29223
|
-
|
29224
|
-
|
29225
|
-
|
29226
|
-
if (state) {
|
29227
|
-
this._sortColumn([state], opt_arg);
|
29228
|
-
}
|
28487
|
+
SortableTitlePlugin.prototype.sortColumn = function (colRef, sortOrder, opt_arg) {
|
28488
|
+
var state = this._prepareSorting(colRef, sortOrder);
|
28489
|
+
if (state) {
|
28490
|
+
this._sortColumn([state], opt_arg);
|
29229
28491
|
}
|
29230
28492
|
};
|
29231
28493
|
|
@@ -29241,7 +28503,14 @@ SortableTitlePlugin.prototype.sortColumns = function (sortOptions, opt_arg) {
|
|
29241
28503
|
var states = [];
|
29242
28504
|
for (var i = 0; i < sortOptions.length; i++) {
|
29243
28505
|
var opt = sortOptions[i];
|
29244
|
-
var
|
28506
|
+
var colRef = opt["colIndex"];
|
28507
|
+
if(colRef < 0 || colRef == null) {
|
28508
|
+
colRef = opt["field"];
|
28509
|
+
}
|
28510
|
+
var state = this._prepareSorting(
|
28511
|
+
colRef,
|
28512
|
+
opt["sortOrder"] || opt["order"]
|
28513
|
+
);
|
29245
28514
|
if (state) {
|
29246
28515
|
states[i] = state;
|
29247
28516
|
}
|
@@ -29270,7 +28539,6 @@ SortableTitlePlugin.prototype.refresh = function () {
|
|
29270
28539
|
|
29271
28540
|
/** @description Perform sorting with the same parameter. Alias to {@link SortableTitlePlugin#refresh}
|
29272
28541
|
* @public
|
29273
|
-
* @override
|
29274
28542
|
* @function
|
29275
28543
|
*/
|
29276
28544
|
SortableTitlePlugin.prototype.restoreUserActions = SortableTitlePlugin.prototype.refresh;
|
@@ -29338,20 +28606,24 @@ SortableTitlePlugin.prototype.setDataColumnNames = SortableTitlePlugin.prototype
|
|
29338
28606
|
* @return {string} field A field used for sorting
|
29339
28607
|
*/
|
29340
28608
|
SortableTitlePlugin.prototype.getColumnSortingField = function (colIndex) {
|
29341
|
-
var
|
28609
|
+
var sortOptions = this._getSortOptions(colIndex);
|
29342
28610
|
// options["field"] is already consolidated from field, sortBy, and sortable properties.
|
29343
|
-
var field = (
|
28611
|
+
var field = (sortOptions) ? sortOptions["field"] : null;
|
29344
28612
|
|
29345
|
-
if (field == null && !this._rowDefMode) { // Old CompositeGrid may
|
28613
|
+
if (field == null && !this._rowDefMode) { // Old CompositeGrid may store sorting field in DataColumnName
|
29346
28614
|
var host = this._hosts[0];
|
29347
28615
|
if (host) {
|
29348
28616
|
field = host.getDataColumnName(colIndex);
|
28617
|
+
if(field && sortOptions) {
|
28618
|
+
sortOptions["field"] = field; // Cache for later use
|
28619
|
+
}
|
29349
28620
|
}
|
29350
28621
|
}
|
29351
28622
|
|
29352
28623
|
return field || "";
|
29353
28624
|
};
|
29354
|
-
/**
|
28625
|
+
/** This is equivalent to setting sortBy in the configuration object.
|
28626
|
+
* @public
|
29355
28627
|
* @param {number} colIndex
|
29356
28628
|
* @param {string|null} field A field used for sorting
|
29357
28629
|
* @param {Function=} sortLogic
|
@@ -29372,21 +28644,26 @@ SortableTitlePlugin.prototype.setColumnSortingField = function (colIndex, field,
|
|
29372
28644
|
}
|
29373
28645
|
}
|
29374
28646
|
};
|
29375
|
-
/**
|
28647
|
+
/** Return array of the fields from the currently sorted columns
|
28648
|
+
* @public
|
29376
28649
|
* @return {!Array.<string>} fields of each sorting states
|
29377
28650
|
*/
|
29378
28651
|
SortableTitlePlugin.prototype.getColumnSortingFields = function () {
|
29379
|
-
var
|
28652
|
+
var len = this._sortStates.length;
|
28653
|
+
var ary = new Array(len);
|
29380
28654
|
var host = this._hosts[0];
|
29381
|
-
|
29382
|
-
for
|
29383
|
-
var sortOptions = this.
|
29384
|
-
|
29385
|
-
|
29386
|
-
|
29387
|
-
|
28655
|
+
|
28656
|
+
for(var i = 0; i < len; ++i) {
|
28657
|
+
var sortOptions = this._sortStates[i];
|
28658
|
+
var field = sortOptions["field"];
|
28659
|
+
if(!field && !this._rowDefMode) {
|
28660
|
+
var colIndex = this._getColumnIndexByOptions(sortOptions); // Slow
|
28661
|
+
field = host.getDataColumnName(colIndex);
|
28662
|
+
if(field) {
|
28663
|
+
sortOptions["field"] = field; // Cache for later use
|
29388
28664
|
}
|
29389
28665
|
}
|
28666
|
+
ary[i] = field || "";
|
29390
28667
|
}
|
29391
28668
|
return ary;
|
29392
28669
|
};
|
@@ -29630,7 +28907,7 @@ SortableTitlePlugin.prototype._proceedSorting = function (hitObj) {
|
|
29630
28907
|
if (this._canClickToSort(hitObj)) {
|
29631
28908
|
var colIndex = hitObj["colIndex"];
|
29632
28909
|
// _proceedSorting() method is always produced by user clicking at the header // Thus, this operation is guaranteed to be a user action
|
29633
|
-
var state = this.
|
28910
|
+
var state = this._prepareSorting(colIndex);
|
29634
28911
|
if (state) {
|
29635
28912
|
this._sortColumn([state], { "isUserAction": true });
|
29636
28913
|
}
|
@@ -29654,6 +28931,14 @@ SortableTitlePlugin.prototype._onMouseDown = function (e) {
|
|
29654
28931
|
}
|
29655
28932
|
};
|
29656
28933
|
/** @private
|
28934
|
+
* @param {string} pluginName
|
28935
|
+
* @return {*|null}
|
28936
|
+
*/
|
28937
|
+
SortableTitlePlugin.prototype._getPlugin = function(pluginName) {
|
28938
|
+
var host = this._hosts[0];
|
28939
|
+
return (host) ? host.getPlugin(pluginName) : null;
|
28940
|
+
};
|
28941
|
+
/** @private
|
29657
28942
|
* @param {Core} grid
|
29658
28943
|
* @param {MouseEvent} e
|
29659
28944
|
*/
|
@@ -29808,23 +29093,36 @@ SortableTitlePlugin.prototype.clearAllColumnSortingSequences = function () {
|
|
29808
29093
|
|
29809
29094
|
|
29810
29095
|
/** @private
|
29811
|
-
* @param {number}
|
29096
|
+
* @param {number|string} colRef Column index or field
|
29812
29097
|
* @param {string=} sortOrder "a" for ascending, "d" for descending, and "n" for no sorting
|
29813
29098
|
* @returns {Object} state Returns null, if nothing is changed
|
29814
29099
|
*/
|
29815
|
-
SortableTitlePlugin.prototype.
|
29816
|
-
if (!this._maxCount) {
|
29100
|
+
SortableTitlePlugin.prototype._prepareSorting = function (colRef, sortOrder) {
|
29101
|
+
if (!this._maxCount) {
|
29102
|
+
return null;
|
29103
|
+
}
|
29817
29104
|
|
29818
|
-
var
|
29819
|
-
var
|
29105
|
+
var colIndex = -1;
|
29106
|
+
var field = "";
|
29107
|
+
var priority = -1;
|
29108
|
+
if(typeof colRef === "number") {
|
29109
|
+
colIndex = colRef;
|
29110
|
+
field = this.getColumnSortingField(colIndex);
|
29111
|
+
priority = this.getSortPriority(colIndex);
|
29112
|
+
} else if(typeof colRef === "string") {
|
29113
|
+
field = colRef;
|
29114
|
+
colIndex = this._getColumnIndexByField(field);
|
29115
|
+
var fields = this.getColumnSortingFields();
|
29116
|
+
priority = fields.indexOf(field);
|
29117
|
+
}
|
29820
29118
|
|
29119
|
+
var curState = (priority >= 0) ? this._sortStates[priority] : null;
|
29821
29120
|
var curOrder = curState ? curState["sortOrder"] : "n";
|
29822
29121
|
|
29823
29122
|
// Getting next sort order
|
29824
29123
|
var nextOrder = "n";
|
29825
|
-
var sortingField = this.getColumnSortingField(colIndex);
|
29826
29124
|
if (sortOrder == null) { // Auto order switch
|
29827
|
-
var sortingSequence = this.getSortingSequence(
|
29125
|
+
var sortingSequence = this.getSortingSequence(field);
|
29828
29126
|
|
29829
29127
|
var sequenceIndex = sortingSequence.indexOf(curOrder);
|
29830
29128
|
if (sequenceIndex < 0) {
|
@@ -29849,10 +29147,16 @@ SortableTitlePlugin.prototype._preSortColumn = function (colIndex, sortOrder) {
|
|
29849
29147
|
}
|
29850
29148
|
|
29851
29149
|
if (nextOrder === "a" || nextOrder === "d") { // Reorder sort states
|
29150
|
+
if(colIndex < 0 && !field) {
|
29151
|
+
return null;
|
29152
|
+
}
|
29852
29153
|
if (!curState) {
|
29853
29154
|
// TODO: Sort state object should not be sortOptions
|
29854
29155
|
curState = this._newSortOptions(colIndex); // This may come with sortLogic
|
29855
29156
|
}
|
29157
|
+
if(colIndex < 0) {
|
29158
|
+
curState["field"] = field;
|
29159
|
+
}
|
29856
29160
|
|
29857
29161
|
this._sortStates.push(curState); // Latest sorting have lowest priority (multiColumn sorting)
|
29858
29162
|
}
|
@@ -29879,7 +29183,7 @@ SortableTitlePlugin.prototype._preSortColumn = function (colIndex, sortOrder) {
|
|
29879
29183
|
|
29880
29184
|
return { // TODO: Refactor this code as it is only used by "columnSorted" event (unnecessarily complex).
|
29881
29185
|
"colIndex": colIndex,
|
29882
|
-
"sortedField":
|
29186
|
+
"sortedField": field,
|
29883
29187
|
"sortOrder": nextOrder || "n",
|
29884
29188
|
"prevOrder": curOrder,
|
29885
29189
|
"clearedSortColIndexes": clearedSortColIndexes
|
@@ -29887,7 +29191,7 @@ SortableTitlePlugin.prototype._preSortColumn = function (colIndex, sortOrder) {
|
|
29887
29191
|
};
|
29888
29192
|
|
29889
29193
|
/** @private
|
29890
|
-
* @param {Array.<Object>} states States from
|
29194
|
+
* @param {Array.<Object>} states States from _prepareSorting for dispatching columnSorted event.
|
29891
29195
|
* @param {Object=} opt_arg Event argument to be sent with preDataSorting event
|
29892
29196
|
* @fires SortableTitlePlugin#preDataSorting
|
29893
29197
|
* @fires SortableTitlePlugin#columnSorted
|
@@ -29914,8 +29218,8 @@ SortableTitlePlugin.prototype._sortColumn = function (states, opt_arg) {
|
|
29914
29218
|
this._dispatch("columnSorted", res);
|
29915
29219
|
};
|
29916
29220
|
|
29917
|
-
/** @
|
29918
|
-
* @
|
29221
|
+
/** @private
|
29222
|
+
* @param {Object} e
|
29919
29223
|
*/
|
29920
29224
|
SortableTitlePlugin.prototype._onColumnAdded = function (e) {
|
29921
29225
|
var t = this;
|
@@ -29937,8 +29241,8 @@ SortableTitlePlugin.prototype._onColumnAdded = function (e) {
|
|
29937
29241
|
}
|
29938
29242
|
};
|
29939
29243
|
|
29940
|
-
/** @
|
29941
|
-
* @
|
29244
|
+
/** @private
|
29245
|
+
* @param {Object} e
|
29942
29246
|
* @fires SortableTitlePlugin#preDataSorting
|
29943
29247
|
* @fires SortableTitlePlugin#columnSorted
|
29944
29248
|
*/
|
@@ -29990,7 +29294,7 @@ SortableTitlePlugin.prototype._sortDataView = function (opt_action) {
|
|
29990
29294
|
sortLogics = new Array(sortCount);
|
29991
29295
|
for (var i = 0; i < sortCount; ++i) {
|
29992
29296
|
orders[i] = this._sortStates[i]["sortOrder"];
|
29993
|
-
sortLogics[i] = this._sortStates[i]["sortLogic"];
|
29297
|
+
sortLogics[i] = this._sortStates[i]["sortLogic"]; // sortLogic can be null
|
29994
29298
|
}
|
29995
29299
|
if(this._rowDefMode) { // DataView in real-time grid has only ROW_DEF column
|
29996
29300
|
c_ref = this._sortStates.map(SortableTitlePlugin._toRowDefField);
|
@@ -30072,7 +29376,7 @@ SortableTitlePlugin.prototype._updateSortableIndicator = function (hostIndex) {
|
|
30072
29376
|
|
30073
29377
|
cell["addClass"]("sortable");
|
30074
29378
|
|
30075
|
-
var priority = t.
|
29379
|
+
var priority = t.getSortPriority(col);
|
30076
29380
|
var state = t._sortStates[priority];
|
30077
29381
|
|
30078
29382
|
var isSorting = state && state["sortOrder"] !== "n";
|
@@ -30143,18 +29447,40 @@ SortableTitlePlugin.prototype._createIconElem = function (icon, fallback) {
|
|
30143
29447
|
};
|
30144
29448
|
|
30145
29449
|
/** @private
|
30146
|
-
|
30147
|
-
* @return {number}
|
29450
|
+
* @param {Object} sortOptions
|
29451
|
+
* @return {number}
|
30148
29452
|
*/
|
30149
|
-
SortableTitlePlugin.prototype.
|
30150
|
-
|
30151
|
-
|
30152
|
-
var
|
30153
|
-
|
29453
|
+
SortableTitlePlugin.prototype._getColumnIndexByOptions = function (sortOptions) {
|
29454
|
+
if(sortOptions) {
|
29455
|
+
var host = this._hosts[0];
|
29456
|
+
var colCount = host ? host.getColumnCount() : 0;
|
29457
|
+
for (var c = 0; c < colCount; ++c) {
|
29458
|
+
var colData = host.getColumnData(c); // Equivalent to _getSortOptions() method
|
29459
|
+
if (colData) {
|
29460
|
+
if(sortOptions === colData["sortableTitle"]) {
|
29461
|
+
return c;
|
29462
|
+
}
|
29463
|
+
}
|
29464
|
+
}
|
29465
|
+
}
|
29466
|
+
return -1;
|
29467
|
+
};
|
29468
|
+
/** @private
|
29469
|
+
* @param {string} field
|
29470
|
+
* @return {number}
|
29471
|
+
*/
|
29472
|
+
SortableTitlePlugin.prototype._getColumnIndexByField = function (field) {
|
29473
|
+
if(field) {
|
29474
|
+
var host = this._hosts[0];
|
29475
|
+
var colCount = host ? host.getColumnCount() : 0;
|
29476
|
+
for (var c = 0; c < colCount; ++c) {
|
29477
|
+
if(field === this.getColumnSortingField(c)) {
|
29478
|
+
return c;
|
29479
|
+
}
|
29480
|
+
}
|
30154
29481
|
}
|
30155
29482
|
return -1;
|
30156
29483
|
};
|
30157
|
-
|
30158
29484
|
/** @private
|
30159
29485
|
* @param {number} colIndex
|
30160
29486
|
* @return {Object}
|
@@ -30177,10 +29503,7 @@ SortableTitlePlugin.prototype._newSortOptions = function (colIndex) {
|
|
30177
29503
|
var host = this._hosts[0];
|
30178
29504
|
var sortOptions = null;
|
30179
29505
|
if (host && colIndex >= 0) {
|
30180
|
-
var colData = host.getColumnData(colIndex);
|
30181
|
-
if (!colData) {
|
30182
|
-
colData = host.setColumnData(colIndex, {});
|
30183
|
-
}
|
29506
|
+
var colData = host.getColumnData(colIndex); // colData is guaranteed to exist
|
30184
29507
|
sortOptions = colData["sortableTitle"];
|
30185
29508
|
if (!sortOptions) {
|
30186
29509
|
sortOptions = colData["sortableTitle"] = {};
|
@@ -30260,8 +29583,6 @@ SortableTitlePlugin._proto = SortableTitlePlugin.prototype;
|
|
30260
29583
|
// Plugins
|
30261
29584
|
|
30262
29585
|
|
30263
|
-
|
30264
|
-
|
30265
29586
|
// Data
|
30266
29587
|
|
30267
29588
|
|
@@ -30313,8 +29634,6 @@ grid.SelectionList = util_SelectionList;
|
|
30313
29634
|
grid.SectionSettings = util_SectionSettings;
|
30314
29635
|
|
30315
29636
|
// Plugins
|
30316
|
-
grid.Plugin = plugins_Plugin;
|
30317
|
-
grid.DragAndDropTitlePlugin = plugins_DragAndDropTitlePlugin;
|
30318
29637
|
grid.SortableTitlePlugin = plugins_SortableTitlePlugin;
|
30319
29638
|
// tsd-enable
|
30320
29639
|
|