@refinitiv-ui/efx-grid 6.0.24 → 6.0.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  import Ext from "../../../tr-grid-util/es6/Ext.js";
2
+ import GroupDefinitions from "../../../tr-grid-util/es6/GroupDefinitions.js"; // eslint-disable-line
2
3
  import ElementWrapper from "./components/ElementWrapper.js";
3
4
  import ILayoutGrid from "./ILayoutGrid.js"; // eslint-disable-line
4
5
  import LayoutGrid from "./LayoutGrid.js";
@@ -382,6 +383,16 @@ declare class Core extends ElementWrapper {
382
383
 
383
384
  public normalizeConfig(configObj: any): any;
384
385
 
386
+ public setColumnGrouping(groupDefs: GroupDefinitions|null): void;
387
+
388
+ public getColumnGroupParentId(colRef: string|number|null): string;
389
+
390
+ public getColumnGroupChildIds(groupId: string): (string)[]|null;
391
+
392
+ public getColumnId(colIndex: number): string;
393
+
394
+ public getColumnIds(): (string)[];
395
+
385
396
  }
386
397
 
387
398
  declare function num(opt_type?: string|null): (ILayoutGrid)[];
@@ -1,4 +1,5 @@
1
1
  import Ext from "../../../tr-grid-util/es6/Ext.js";
2
+ import GroupDefinitions from "../../../tr-grid-util/es6/GroupDefinitions.js"; // eslint-disable-line
2
3
  import ElementWrapper from "./components/ElementWrapper.js";
3
4
  import ILayoutGrid from "./ILayoutGrid.js"; // eslint-disable-line
4
5
  import LayoutGrid from "./LayoutGrid.js";
@@ -74,6 +75,9 @@ var Core = function (opt_initializer) {
74
75
  var _t = this;
75
76
 
76
77
  // Initialize method binding
78
+ _t.getColumnId = _t.getColumnId.bind(_t);
79
+ _t.getColumnIndex = _t.getColumnIndex.bind(_t);
80
+
77
81
  _t._onMouseMove = _t._onMouseMove.bind(_t);
78
82
  _t._onRowHightlighted = _t._onRowHightlighted.bind(_t);
79
83
 
@@ -521,6 +525,10 @@ Core.prototype._preserveGridSize = false;
521
525
  * @private
522
526
  */
523
527
  Core.prototype._rowHeightTimerId = 0;
528
+ /** @type {GroupDefinitions}
529
+ * @private
530
+ */
531
+ Core.prototype._groupDefs = null;
524
532
  //#region Public Methods
525
533
 
526
534
  /**
@@ -528,7 +536,7 @@ Core.prototype._rowHeightTimerId = 0;
528
536
  * @return {string}
529
537
  */
530
538
  Core.getVersion = function () {
531
- return "5.1.32";
539
+ return "5.1.34";
532
540
  };
533
541
  /** {@link ElementWrapper#dispose}
534
542
  * @override
@@ -1656,7 +1664,7 @@ Core.prototype._moveColumn = function (fromCol, destCol) {
1656
1664
  vEnd = this._colVirtualizer.getLastIndexInView();
1657
1665
  }
1658
1666
 
1659
- var colId = this._getColumnId(fromCol);
1667
+ var colId = this.getColumnId(fromCol);
1660
1668
  this._layoutX.moveLane(fromCol, destCol);
1661
1669
  var sectionCount = this._settings.length;
1662
1670
  for (var i = 0; i < sectionCount; ++i) {
@@ -1776,6 +1784,11 @@ Core.prototype._deserializeColumn = function (index, jsonObj) {
1776
1784
  // TODO: Load specific styles for each column type (e.g. "content", "title", "header")
1777
1785
 
1778
1786
  var colDef = this._getColumnDef(index);
1787
+ var colId = jsonObj["id"];
1788
+ if(colId && typeof colId === "string") {
1789
+ colDef["id"] = colId; // WARNING: We do not guarantee uniqueness of user id
1790
+ }
1791
+
1779
1792
  var value = jsonObj["dataColumnName"];
1780
1793
  if (value != null) {
1781
1794
  colDef["dataColumnName"] = value;
@@ -3219,14 +3232,19 @@ Core.prototype.getRelativePosition = function (obj, context) {
3219
3232
  return ret_obj;
3220
3233
  };
3221
3234
 
3222
- /** @public
3223
- * @param {string} str data column name
3224
- * @return {number} Return negative if the mouse is not hit
3235
+ /** Find column index by column id or data column name
3236
+ * @public
3237
+ * @param {string} str Column id or data column name
3238
+ * @return {number} Return negative value if there is no match
3225
3239
  */
3226
3240
  Core.prototype.getColumnIndex = function (str) {
3227
- for(var c = this.getColumnCount(); --c >= 0;) {
3228
- if(str === this.getDataColumnName(c)) {
3229
- return c;
3241
+ if(str) {
3242
+ var colCount = this.getColumnCount();
3243
+ for(var c = 0; c < colCount; ++c) {
3244
+ var colDef = this._getColumnDef(c);
3245
+ if(str === colDef["id"] || str === colDef["dataColumnName"]) {
3246
+ return c;
3247
+ }
3230
3248
  }
3231
3249
  }
3232
3250
  return -1;
@@ -4111,6 +4129,37 @@ Core.prototype.normalizeConfig = function (configObj) {
4111
4129
 
4112
4130
  return configObj;
4113
4131
  };
4132
+ /** @public
4133
+ * @param {GroupDefinitions} groupDefs
4134
+ */
4135
+ Core.prototype.setColumnGrouping = function (groupDefs) {
4136
+ this._groupDefs = groupDefs || null;
4137
+ };
4138
+ /** @public
4139
+ * @param {string|number} colRef
4140
+ * @return {string} Return group id of immediate group parent. Return empty string, if no parent is found.
4141
+ */
4142
+ Core.prototype.getColumnGroupParentId = function (colRef) {
4143
+ if(this._groupDefs) {
4144
+ var colId = (typeof colRef === "number") ? this.getColumnId(colRef) : colRef;
4145
+ return this._groupDefs.getParentId(colId);
4146
+ }
4147
+ return "";
4148
+ };
4149
+
4150
+ /** @public
4151
+ * @param {string} groupId
4152
+ * @return {Array.<string>} Return array of column id. Return null if the specified group has no child
4153
+ */
4154
+ Core.prototype.getColumnGroupChildIds = function (groupId) {
4155
+ if(this._groupDefs) {
4156
+ var ary = this._groupDefs.getLeafDescendants(groupId);
4157
+ if(ary && ary.length > 0) {
4158
+ return ary;
4159
+ }
4160
+ }
4161
+ return null;
4162
+ };
4114
4163
  //#endregion Public Methods
4115
4164
 
4116
4165
  //#region Private Methods
@@ -4768,13 +4817,35 @@ Core.prototype._getNestedColumnDef = function (colIndex, firstLvl, secondLvl) {
4768
4817
  }
4769
4818
  return def;
4770
4819
  };
4820
+
4771
4821
  /** @public
4822
+ * @param {number} colIndex
4823
+ * @return {string} Return empty string if the specified column does not exist
4824
+ */
4825
+ Core.prototype.getColumnId = function (colIndex) {
4826
+ if(colIndex >= 0 && colIndex < this.getColumnCount()) {
4827
+ return this._getColumnDef(colIndex)["id"] || "";
4828
+ }
4829
+ return "";
4830
+ };
4831
+ /** @deprecated
4832
+ * @public
4833
+ * @function
4772
4834
  * @ignore
4773
4835
  * @param {number} colIndex
4774
4836
  * @return {string}
4775
4837
  */
4776
- Core.prototype._getColumnId = function (colIndex) {
4777
- return this._getColumnDef(colIndex)["id"];
4838
+ Core.prototype._getColumnId = Core.prototype.getColumnId;
4839
+ /** @public
4840
+ * @return {!Array.<string>} Return all column ids from existing column
4841
+ */
4842
+ Core.prototype.getColumnIds = function () {
4843
+ var colCount = this.getColumnCount();
4844
+ var ary = new Array(colCount);
4845
+ for(var c = 0; c < colCount; ++c) {
4846
+ ary[c] = this._getColumnDef(c)["id"] || "";
4847
+ }
4848
+ return ary;
4778
4849
  };
4779
4850
 
4780
4851
 
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.24" };
3
+ window.EFX_GRID = { version: "6.0.25" };