@refinitiv-ui/efx-grid 6.0.20 → 6.0.21

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/grid/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import {Grid} from "./lib/efx-grid.js";
2
2
  export {Grid}
3
- window.EFX_GRID = { version: "6.0.20" };
3
+ window.EFX_GRID = { version: "6.0.21" };
@@ -44797,17 +44797,136 @@ Grid.prototype.getAllFields = function() {
44797
44797
  return this._connector.getAllFields();
44798
44798
  };
44799
44799
  /** Freeze the column at the left side of the table starting from index 0 to the specified colIndex
44800
- * If no index is specified (null or undefined index), unfreeze all columns.
44801
- * @public
44802
- * @param {number=} colIndex Negative index is equivalent to null value
44803
- * @param {number=} pinnedRightColumns Number of columns to be pinned/snapped on the right side
44804
- */
44800
+ * If no index is specified (null or undefined index), unfreeze all columns.
44801
+ * @public
44802
+ * @param {number=} colIndex Negative index is equivalent to null value
44803
+ * @param {number=} pinnedRightColumns Number of columns to be pinned/snapped on the right side
44804
+ */
44805
44805
  Grid.prototype.freezeColumn = function(colIndex, pinnedRightColumns) {
44806
44806
  if(colIndex == null) {
44807
44807
  colIndex = -1;
44808
44808
  }
44809
44809
  this._grid.freezeColumn(colIndex, pinnedRightColumns);
44810
44810
  };
44811
+ /** Pin column to the left side by moving the specified column to the rightmost of the frozen columns. <br>
44812
+ * The method will do nothing if the specified column is already pinned to the left side
44813
+ * @public
44814
+ * @param {Grid~ColumnReference|Array.<Grid~ColumnReference>} colRef
44815
+ * @return {boolean}
44816
+ */
44817
+ Grid.prototype.pinColumn = function(colRef) {
44818
+ if(Array.isArray(colRef)) {
44819
+ var ary = colRef;
44820
+ var len = ary.length;
44821
+
44822
+ var dirty = 0;
44823
+ for(var i = 0; i < len; ++i) {
44824
+ dirty |= this._pinColumn(ary[i]);
44825
+ }
44826
+ return dirty ? true : false;
44827
+ }
44828
+ return this._pinColumn(colRef);
44829
+ };
44830
+ /** @private
44831
+ * @param {Grid~ColumnReference} colRef
44832
+ * @return {boolean}
44833
+ */
44834
+ Grid.prototype._pinColumn = function(colRef) {
44835
+ var colIndex = this.getColumnIndex(colRef);
44836
+ if(colIndex < 0) {
44837
+ return false;
44838
+ }
44839
+ var pinnedCount = this._grid.getFrozenColumnCount();
44840
+ if(colIndex < pinnedCount) {
44841
+ return false; // The column is already pinned area
44842
+ }
44843
+ if(!pinnedCount) {
44844
+ var stationaryIdx = this._grid.getStationaryColumnIndex();
44845
+ if(stationaryIdx >= 0) {
44846
+ pinnedCount = stationaryIdx;
44847
+ if(colIndex > stationaryIdx) {
44848
+ pinnedCount++;
44849
+ }
44850
+ }
44851
+ }
44852
+
44853
+ this.moveColumnById(colIndex, pinnedCount);
44854
+ this._grid.freezeColumn(pinnedCount);
44855
+ return true;
44856
+ };
44857
+ /** Unpin column from the left side by moving the specified column to the end of the frozen columns. <br>
44858
+ * The method will do nothing if the specified column is not pinned on the left side.
44859
+ * @public
44860
+ * @param {Grid~ColumnReference|Array.<Grid~ColumnReference>} colRef
44861
+ * @param {Grid~ColumnReference=} dest The unpinned column will be placed before the destination position after the operation
44862
+ * @return {boolean}
44863
+ */
44864
+ Grid.prototype.unpinColumn = function(colRef, dest) {
44865
+ if(Array.isArray(colRef)) {
44866
+ var ary = colRef;
44867
+ var len = ary.length;
44868
+
44869
+ var dirty = 0;
44870
+ for(var i = 0; i < len; ++i) {
44871
+ dirty |= this._unpinColumn(ary[i], dest);
44872
+ }
44873
+ return dirty ? true : false;
44874
+ }
44875
+ return this._unpinColumn(colRef, dest);
44876
+ };
44877
+ /** @private
44878
+ * @param {Grid~ColumnReference} colRef
44879
+ * @param {Grid~ColumnReference=} dest The unpinned column will be placed before the destination position after the operation
44880
+ * @return {boolean}
44881
+ */
44882
+ Grid.prototype._unpinColumn = function(colRef, dest) {
44883
+ var colIndex = this.getColumnIndex(colRef);
44884
+ if(colIndex < 0) {
44885
+ return false;
44886
+ }
44887
+ var pinnedCount = this._grid.getFrozenColumnCount();
44888
+ if(!pinnedCount) {
44889
+ return false;
44890
+ }
44891
+ if(colIndex >= pinnedCount) {
44892
+ return false; // The column is outside of frozen area
44893
+ }
44894
+ var srcId = null;
44895
+ var destId = null;
44896
+ if(dest != null) {
44897
+ var destIdx = this.getColumnIndex(dest);
44898
+ destId = this.getColumnId(destIdx);
44899
+ srcId = this.getColumnId(colIndex);
44900
+ }
44901
+
44902
+ var stationaryIdx = this._grid.getStationaryColumnIndex();
44903
+
44904
+ if(colIndex > stationaryIdx) {
44905
+ this.moveColumnById(colIndex, pinnedCount);
44906
+ }
44907
+
44908
+ this._grid.freezeColumn(pinnedCount - 2); // Column index is used for freezing
44909
+
44910
+ if(colIndex > stationaryIdx) {
44911
+ if(destId != null) {
44912
+ this.moveColumnById(srcId, destId);
44913
+ }
44914
+ }
44915
+
44916
+ return true;
44917
+ };
44918
+ /** A shorthand to unpin all columns from the left hand side
44919
+ * @public
44920
+ * @return {boolean}
44921
+ */
44922
+ Grid.prototype.unpinAllColumns = function() {
44923
+ var pinnedCount = this._grid.getFrozenColumnCount();
44924
+ if(!pinnedCount) {
44925
+ return false;
44926
+ }
44927
+ this._grid.freezeColumn(-1); // Column index is used for freezing
44928
+ return true;
44929
+ };
44811
44930
 
44812
44931
  /** @private
44813
44932
  * @param {Object} e