@refinitiv-ui/efx-grid 6.0.84 → 6.0.86

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/lib/core/dist/core.js +241 -153
  2. package/lib/core/dist/core.min.js +1 -1
  3. package/lib/core/es6/data/DataView.d.ts +4 -0
  4. package/lib/core/es6/data/DataView.js +23 -0
  5. package/lib/core/es6/grid/Core.d.ts +0 -4
  6. package/lib/core/es6/grid/Core.js +34 -22
  7. package/lib/core/es6/grid/plugins/SortableTitlePlugin.d.ts +13 -3
  8. package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +184 -131
  9. package/lib/grid/index.js +1 -1
  10. package/lib/rt-grid/dist/rt-grid.js +275 -159
  11. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  12. package/lib/rt-grid/es6/ColumnDefinition.js +1 -2
  13. package/lib/rt-grid/es6/Grid.js +7 -7
  14. package/lib/tr-grid-checkbox/es6/Checkbox.d.ts +2 -0
  15. package/lib/tr-grid-checkbox/es6/Checkbox.js +38 -0
  16. package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +3 -4
  17. package/lib/tr-grid-filter-input/es6/FilterInput.js +32 -3
  18. package/lib/tr-grid-row-filtering/es6/RowFiltering.d.ts +4 -1
  19. package/lib/tr-grid-row-filtering/es6/RowFiltering.js +3 -0
  20. package/lib/tr-grid-textformatting/es6/TextFormatting.js +13 -2
  21. package/lib/tr-grid-util/es6/Dom.d.ts +1 -1
  22. package/lib/tr-grid-util/es6/Dom.js +1 -1
  23. package/lib/tr-grid-util/es6/ExpressionParser.js +1 -1
  24. package/lib/tr-grid-util/es6/FieldFormatter.js +4 -2
  25. package/lib/tr-grid-util/es6/FilterBuilder.d.ts +1 -1
  26. package/lib/tr-grid-util/es6/FilterBuilder.js +1 -1
  27. package/lib/tr-grid-util/es6/NumberFormatter.js +2 -2
  28. package/lib/tr-grid-util/es6/PercentBar.d.ts +1 -1
  29. package/lib/tr-grid-util/es6/PercentBar.js +1 -1
  30. package/lib/tr-grid-util/es6/RangeBar.d.ts +1 -1
  31. package/lib/tr-grid-util/es6/RangeBar.js +8 -7
  32. package/lib/tr-grid-util/es6/TextHighlighter.d.ts +0 -2
  33. package/lib/tr-grid-util/es6/TextHighlighter.js +1 -6
  34. package/lib/tr-grid-util/es6/formula/Formula.js +1 -1
  35. package/lib/tr-grid-util/es6/formula/VariableToken.js +1 -1
  36. package/lib/tr-grid-util/es6/formula/functions/Excel.d.ts +1 -1
  37. package/lib/tr-grid-util/es6/formula/functions/Excel.js +1 -1
  38. package/lib/tr-grid-util/es6/index.js +1 -1
  39. package/lib/tr-grid-util/es6/jet/DataGenerator.d.ts +1 -1
  40. package/lib/tr-grid-util/es6/jet/DataGenerator.js +1 -1
  41. package/lib/types/es6/Core/data/DataView.d.ts +4 -0
  42. package/lib/types/es6/Core/grid/Core.d.ts +0 -4
  43. package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +13 -3
  44. package/lib/types/es6/RowFiltering.d.ts +4 -1
  45. package/lib/versions.json +6 -6
  46. package/package.json +1 -1
@@ -20967,6 +20967,17 @@ DataView.prototype.getExpansionParents = function (from, to) {
20967
20967
  return parentMapping;
20968
20968
  };
20969
20969
 
20970
+ /**
20971
+ * @public
20972
+ * @param {string} rid
20973
+ * @return {string} parent row id
20974
+ */
20975
+ DataView.prototype.getExpansionParentByRowId = function(rid) {
20976
+ if(this._expansionChildren) {
20977
+ return this._expansionChildren[rid] || "";
20978
+ }
20979
+ return "";
20980
+ };
20970
20981
  /** Check if the specified row is itself a row expansion.
20971
20982
  * @public
20972
20983
  * @param {string} rid rowId
@@ -20989,6 +21000,18 @@ DataView.prototype.hasRowExpansion = function(rid) {
20989
21000
  }
20990
21001
  return false;
20991
21002
  };
21003
+ /**
21004
+ * @public
21005
+ * @param {string} rowId
21006
+ * @return {number}
21007
+ */
21008
+ DataView.prototype.getRowExpansionCount = function(rowId) {
21009
+ if(this._expansionMap) {
21010
+ return this._expansionMap[rowId] || 0;
21011
+ }
21012
+ return 0;
21013
+ };
21014
+
20992
21015
  /** Get row Id of the row expansion by providing the row Id of the row with row expansion (not row expansion itself). This is NOT recommended for normal usage, since the row expansion contains no data in the DataView
20993
21016
  * @public
20994
21017
  * @param {string} rid rowId
@@ -26155,7 +26178,7 @@ Core_Core.prototype._hasPendingRowChange = false;
26155
26178
  * @return {string}
26156
26179
  */
26157
26180
  Core_Core.getVersion = function () {
26158
- return "5.1.87";
26181
+ return "5.1.90";
26159
26182
  };
26160
26183
  /** {@link ElementWrapper#dispose}
26161
26184
  * @override
@@ -28270,27 +28293,30 @@ Core_Core.prototype.preserveGridSize = function (preserve) {
28270
28293
  };
28271
28294
  /** @public
28272
28295
  * @param {number} colIndex
28273
- * @return {Object} userData
28296
+ * @return {!Object} Column data object
28274
28297
  */
28275
28298
  Core_Core.prototype.getColumnData = function (colIndex) {
28276
- return this._getColumnDef(colIndex)["columnData"] || null;
28299
+ return this._getColumnDef(colIndex)["columnData"];
28277
28300
  };
28278
28301
  /** @public
28302
+ * @deprecated
28303
+ * @ignore
28279
28304
  * @param {number} colIndex
28280
28305
  * @param {Object} userData
28281
28306
  * @return {Object}
28282
28307
  */
28283
- Core_Core.prototype.setColumnData = function (colIndex, userData) { // TODO: Deprecate this method
28284
- this._getColumnDef(colIndex)["columnData"] = userData;
28308
+ Core_Core.prototype.setColumnData = function (colIndex, userData) {
28309
+ this._getColumnDef(colIndex)["columnData"] = userData || {};
28285
28310
  return userData;
28286
28311
  };
28287
28312
  /** @public
28313
+ * @function
28314
+ * @deprecated
28315
+ * @ignore
28288
28316
  * @param {number} colIndex
28289
28317
  * @return {!Object}
28290
28318
  */
28291
- Core_Core.prototype.newColumnData = function (colIndex) {
28292
- return this.getColumnData(colIndex) || {};
28293
- };
28319
+ Core_Core.prototype.newColumnData = Core_Core.prototype.getColumnData;
28294
28320
  /** @public
28295
28321
  * @param {number} colIndex
28296
28322
  * @param {boolean=} alwaysRender
@@ -28304,10 +28330,7 @@ Core_Core.prototype.setAlwaysRenderColumn = function(colIndex, alwaysRender) {
28304
28330
  */
28305
28331
  Core_Core.prototype._isAlwaysRenderColumn = function (colIndex) {
28306
28332
  var colData = this.getColumnData(colIndex);
28307
- if(colData) {
28308
- return colData["alwaysRender"] === true;
28309
- }
28310
- return false;
28333
+ return colData["alwaysRender"] === true;
28311
28334
  };
28312
28335
 
28313
28336
  /** @public
@@ -30462,25 +30485,35 @@ Core_Core.prototype._dispatchRowExpansionBinding = function (e) {
30462
30485
 
30463
30486
  var fromR = /** @type{number} */(e["fromRowIndex"]);
30464
30487
  var toR = /** @type{number} */(e["toRowIndex"]);
30465
- var parents = dataView.getExpansionParents(fromR, toR);
30466
30488
  var rids = dataView.getVisibleRowIds(true);
30467
30489
  var section = /** @type{ILayoutGrid} */(e["section"]);
30468
30490
 
30469
30491
  e["rowData"] = null;
30470
30492
  e["cell"] = null;
30471
- for (var r = fromR; r < toR; ++r) {
30472
- var parentRid = parents[r];
30493
+ var lastRowIndexChanged = false;
30494
+ for (var r = toR - 1; r >= fromR; --r) {
30495
+ var rowId = dataView.getRowId(r);
30496
+ if(!lastRowIndexChanged) {
30497
+ var reCount = dataView.getRowExpansionCount(rowId);
30498
+ if(reCount > 0){
30499
+ r = r + reCount + 1; // include parent row
30500
+ lastRowIndexChanged = true;
30501
+ continue;
30502
+ }
30503
+ }
30504
+
30473
30505
  var ctxRow = section.getContextRow(r);
30474
- if(parentRid) { // Previous row is the row with expansion
30475
- e["originalRowData"] = dataView.getRowData(parentRid);
30476
- e["originalRowId"] = parentRid;
30506
+ var parentId = dataView.getExpansionParentByRowId(rowId);
30507
+ if(parentId) { // dispatch to render row expansion
30508
+ e["originalRowData"] = dataView.getRowData(parentId);
30509
+ e["originalRowId"] = parentId;
30477
30510
  e["rowExpansion"] = ctxRow["rowExpansion"] = true;
30478
- } else if(ctxRow["rowExpansion"]) {
30511
+ } else if(ctxRow["rowExpansion"] ){ // dispose cases
30479
30512
  e["originalRowData"] = null;
30480
30513
  e["originalRowId"] = null;
30481
30514
  e["rowExpansion"] = ctxRow["rowExpansion"] = false;
30482
- } else {
30483
- continue; // There is no need to dispatch the event for normal row
30515
+ } else { // normal row no need to dispatch
30516
+ continue;
30484
30517
  }
30485
30518
  e["rowId"] = rids[r];
30486
30519
  e["rowIndex"] = r;
@@ -30763,7 +30796,9 @@ Core_Core.prototype._getColumnDef = function (colIndex) {
30763
30796
  }
30764
30797
  return def;
30765
30798
  }
30766
- return {};
30799
+ return {
30800
+ "columnData": {}
30801
+ };
30767
30802
  };
30768
30803
  /** Retrieve 1 or 2 level of nested object definition
30769
30804
  * @private
@@ -31620,16 +31655,26 @@ es6_Ext.inherits(SortableTitlePlugin, event_EventDispatcher);
31620
31655
  * @typedef {"a" | "ascending" | "d" | "descending" | "n" | null} SortableTitlePlugin~SortOrder
31621
31656
  */
31622
31657
 
31623
- /** The sorting object which will be used for initialSort config.
31658
+ /** An object that specifies how sorting should be performed
31624
31659
  * @typedef {Object} SortableTitlePlugin~InitialSort
31625
- * @property {number=} colIndex Index of the column
31626
- * @property {string=} colId column id of the column
31627
- * @property {string=} field field of the column
31660
+ * @property {number=} colIndex Column index of a column to be sorted
31661
+ * @property {string=} colId Column id of a column to be sorted
31662
+ * @property {string=} field Field of a column to be sorted
31628
31663
  * @property {SortableTitlePlugin~SortOrder=} sortOrder=null Set to "d" for descending order and "a" for ascending order
31629
- * @property {SortableTitlePlugin~SortOrder=} order Alias of sortOrder
31664
+ * @property {SortableTitlePlugin~SortOrder=} order Alias to sortOrder
31630
31665
  */
31631
31666
  SortableTitlePlugin.InitialSort;
31632
31667
 
31668
+ /** An object that specifies how sorting should be performed
31669
+ * @typedef {Object} SortableTitlePlugin~SortingDefinition
31670
+ * @property {number=} colIndex Column index of a column to be sorted
31671
+ * @property {string=} colId Column id of a column to be sorted
31672
+ * @property {string=} field Field of a column to be sorted
31673
+ * @property {SortableTitlePlugin~SortOrder=} sortOrder=null Set to "d" for descending order and "a" for ascending order
31674
+ * @property {SortableTitlePlugin~SortOrder=} order Alias to sortOrder
31675
+ */
31676
+ SortableTitlePlugin.SortingDefinition;
31677
+
31633
31678
  /** The sorting properties for column option.
31634
31679
  * @typedef {Object} SortableTitlePlugin~ColumnOptions
31635
31680
  * @property {boolean=} sortable=false If enable, the column can be sorted by user click
@@ -31645,7 +31690,7 @@ SortableTitlePlugin.ColumnOptions;
31645
31690
 
31646
31691
  /** The configuration object for sorting options. This can be defined by `sorting` property in CompositeGrid configuration object.
31647
31692
  * @typedef {Object} SortableTitlePlugin~Options
31648
- * @property {(SortableTitlePlugin~InitialSort|Array.<SortableTitlePlugin.InitialSort>)=} initialSort=null Set this config to initiate sorting after grid is created.
31693
+ * @property {(SortableTitlePlugin~InitialSort|Array.<SortableTitlePlugin.SortingDefinition>)=} initialSort=null Set this config to initiate sorting after grid is created.
31649
31694
  * @property {(boolean|number)=} multicolumn=false Allow multiple columns to be sorted at the same time. If number is defined, it is treated as maximum number of column to be sorted.
31650
31695
  * @property {(boolean|number)=} multiColumn=false Alias to `multicolumn`
31651
31696
  * @property {boolean=} threeStatesSorting=false If enabled, sorting will cycle through ascending, descending and original order states. This option is deprecated in favor of sortingSequence option
@@ -31705,7 +31750,7 @@ SortableTitlePlugin.prototype._delayInterval = 0;
31705
31750
  */
31706
31751
  SortableTitlePlugin.prototype._lastMouseDown = 0;
31707
31752
  /** @private
31708
- * @type {SortableTitlePlugin.InitialSort}
31753
+ * @type {SortableTitlePlugin.SortingDefinition}
31709
31754
  */
31710
31755
  SortableTitlePlugin.prototype._initialSort = null;
31711
31756
  /** @private
@@ -32028,7 +32073,8 @@ SortableTitlePlugin.prototype.getConfigObject = function (gridOptions) {
32028
32073
  }
32029
32074
  field = opt["field"];
32030
32075
  if (field) {
32031
- if(col["field"] != null && col["field"] !== field) { // Core does not have field properties, so when you try to call getConfigObject in Core, it will return sortBy too.
32076
+ // WARNING: When Core's column has no field, sortBy property does not get returned
32077
+ if(col["field"] != null && col["field"] !== field) {
32032
32078
  col["sortBy"] = field;
32033
32079
  } // else The default value is an empty sortBy, which refers to the same column field by default.
32034
32080
 
@@ -32246,18 +32292,38 @@ SortableTitlePlugin.prototype.getSortOrder = function (colIndex) {
32246
32292
  * @return {number} Return negative value if there is no sorted column
32247
32293
  */
32248
32294
  SortableTitlePlugin.prototype.getSortedColumnIndex = function (priority) {
32249
- return this._getColumnIndexByOptions(this._sortStates[priority || 0]);
32295
+ return this._getColumnIndex(this._sortStates[priority || 0]);
32250
32296
  };
32251
32297
  /** 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
32252
32298
  * @public
32253
32299
  * @param {number} colIndex
32300
+ * @param {string=} colRef field or column id
32254
32301
  * @return {number}
32255
32302
  */
32256
- SortableTitlePlugin.prototype.getSortPriority = function (colIndex) {
32257
- var len = this._sortStates.length;
32258
- for (var i = 0; i < len; ++i) {
32259
- if (this._sortStates[i] === this._getSortOptions(colIndex)) {
32260
- return i;
32303
+ SortableTitlePlugin.prototype.getSortPriority = function (colIndex, colRef) {
32304
+ var host = this._hosts[0];
32305
+ if(host) {
32306
+ var i;
32307
+ var len = this._sortStates.length;
32308
+ if(colIndex >= 0) {
32309
+ var colId = host.getColumnId(colIndex);
32310
+ if(colId) {
32311
+ for(i = 0; i < len; ++i) {
32312
+ if(this._sortStates[i]["colId"] === colId) {
32313
+ return i;
32314
+ }
32315
+ }
32316
+ }
32317
+ } else if(colRef) {
32318
+ for(i = 0; i < len; ++i) {
32319
+ var sortState = this._sortStates[i];
32320
+ if(sortState["colId"] === colRef) {
32321
+ return i;
32322
+ }
32323
+ if(sortState["field"] === colRef) {
32324
+ return i;
32325
+ }
32326
+ }
32261
32327
  }
32262
32328
  }
32263
32329
  return -1;
@@ -32270,7 +32336,7 @@ SortableTitlePlugin.prototype.isColumnSorted = function (colIndex) {
32270
32336
  return this.getSortPriority(colIndex) >= 0;
32271
32337
  };
32272
32338
  /** @public
32273
- * @return {Array.<Object>} Array of object with "colIndex" and "sortOrder"
32339
+ * @return {Array.<Object>} Array of objects with colIndex, colId, field, and sortOrder properties
32274
32340
  */
32275
32341
  SortableTitlePlugin.prototype.getSortedColumns = function () {
32276
32342
  var len = this._sortStates.length;
@@ -32280,12 +32346,21 @@ SortableTitlePlugin.prototype.getSortedColumns = function () {
32280
32346
  for (var i = 0; i < len; ++i) {
32281
32347
  var colIndex = this.getSortedColumnIndex(i);
32282
32348
  var state = this._sortStates[i];
32283
- arr[i] = {
32284
- "colIndex": colIndex,
32285
- "colId": this._getColumnId(colIndex),
32286
- "field": state["field"] || "",
32287
- "sortOrder": state["sortOrder"] || "n"
32288
- };
32349
+ var retObj = {};
32350
+ var colId = "";
32351
+ if(colIndex >= 0) {
32352
+ retObj["colIndex"] = colIndex;
32353
+ colId = this._getColumnId(colIndex);
32354
+ }
32355
+ if(colId) {
32356
+ retObj["colId"] = colId;
32357
+ }
32358
+ var field = state["field"] || "";
32359
+ if(field) {
32360
+ retObj["field"] = field;
32361
+ }
32362
+ retObj["sortOrder"] = state["sortOrder"] || "n";
32363
+ arr[i] = retObj;
32289
32364
  }
32290
32365
  return arr;
32291
32366
  };
@@ -32304,35 +32379,22 @@ SortableTitlePlugin.prototype.isSorting = function () {
32304
32379
  * @fires SortableTitlePlugin#columnSorted
32305
32380
  */
32306
32381
  SortableTitlePlugin.prototype.sortColumn = function (colRef, sortOrder, opt_arg) {
32307
- var state = this._prepareSorting(colRef, sortOrder);
32308
- if (state) {
32309
- this._sortColumn([state], opt_arg);
32310
- }
32382
+ this._sortColumn(this._prepareSorting(colRef, sortOrder), opt_arg);
32311
32383
  };
32312
32384
 
32313
32385
  /** Sort multiple columns at once
32314
32386
  * @public
32315
- * @param {Array.<SortableTitlePlugin.InitialSort>} sortOptions Input an array to specify the multiple column sort order
32387
+ * @param {Array.<SortableTitlePlugin.SortingDefinition>} sortOptions Input an array to specify the multiple column sort order
32316
32388
  * @param {Object=} opt_arg Event argument to be sent with preDataSorting event
32317
32389
  * @fires SortableTitlePlugin#preDataSorting
32318
32390
  * @fires SortableTitlePlugin#columnSorted
32319
32391
  */
32320
32392
  SortableTitlePlugin.prototype.sortColumns = function (sortOptions, opt_arg) {
32321
32393
  if (Array.isArray(sortOptions)) {
32322
- var states = [];
32323
- for (var i = 0; i < sortOptions.length; i++) {
32324
- var opt = sortOptions[i];
32325
- var colRef = opt["colId"] || opt["field"];
32326
- if(colRef == null) {
32327
- colRef = opt["colIndex"];
32328
- }
32329
- var state = this._prepareSorting(
32330
- colRef,
32331
- opt["sortOrder"] || opt["order"]
32332
- );
32333
- if (state) {
32334
- states.push(state);
32335
- }
32394
+ var len = sortOptions.length;
32395
+ var states = new Array(len);
32396
+ for (var i = 0; i < len; i++) {
32397
+ states[i] = this._prepareSorting(sortOptions[i]);
32336
32398
  }
32337
32399
  this._sortColumn(states, opt_arg);
32338
32400
  }
@@ -32433,7 +32495,10 @@ SortableTitlePlugin.prototype.getColumnSortingField = function (colIndex) {
32433
32495
  if (field == null && !this._rowDefMode) { // Old CompositeGrid may store sorting field in DataColumnName
32434
32496
  var host = this._hosts[0];
32435
32497
  if (host) {
32436
- field = host.getDataColumnName(colIndex);
32498
+ field = host.getColumnField(colIndex);
32499
+ if(!field) {
32500
+ field = host.getDataColumnName(colIndex);
32501
+ }
32437
32502
  if(field && sortOptions) {
32438
32503
  sortOptions["field"] = field; // Cache for later use
32439
32504
  }
@@ -32468,28 +32533,20 @@ SortableTitlePlugin.prototype.setColumnSortingField = function (colIndex, field,
32468
32533
  }
32469
32534
  }
32470
32535
  };
32536
+
32537
+ /** @private
32538
+ * @param {Object} sortState
32539
+ * @returns {string}
32540
+ */
32541
+ var _toField = function(sortState) {
32542
+ return sortState["field"] || "";
32543
+ };
32471
32544
  /** Return array of the fields from the currently sorted columns
32472
32545
  * @public
32473
32546
  * @return {!Array.<string>} fields of each sorting states
32474
32547
  */
32475
32548
  SortableTitlePlugin.prototype.getColumnSortingFields = function () {
32476
- var len = this._sortStates.length;
32477
- var ary = new Array(len);
32478
- var host = this._hosts[0];
32479
-
32480
- for(var i = 0; i < len; ++i) {
32481
- var sortOptions = this._sortStates[i];
32482
- var field = sortOptions["field"];
32483
- if(!field && !this._rowDefMode) {
32484
- var colIndex = this._getColumnIndexByOptions(sortOptions); // Slow
32485
- field = host.getDataColumnName(colIndex);
32486
- if(field) {
32487
- sortOptions["field"] = field; // Cache for later use
32488
- }
32489
- }
32490
- ary[i] = field || "";
32491
- }
32492
- return ary;
32549
+ return this._sortStates.map(_toField);
32493
32550
  };
32494
32551
 
32495
32552
  /** This is deprecated in favor of setSortingSequence method. Move existing sort order to the front of sorting sequence. New sort order will be added, if the specified sort order does not exist in current sorting sequence.
@@ -32498,7 +32555,6 @@ SortableTitlePlugin.prototype.getColumnSortingFields = function () {
32498
32555
  * @param {string=} sortOrder="a" "ascending", "descending", "none"
32499
32556
  * @see {@link SortableTitlePlugin#setSortingSequence}
32500
32557
  */
32501
-
32502
32558
  SortableTitlePlugin.prototype.setFirstSortOrder = function (colIdentifier, sortOrder) {
32503
32559
  if (sortOrder) {
32504
32560
  sortOrder = SortableTitlePlugin._toSortOrder(sortOrder);
@@ -32716,10 +32772,8 @@ SortableTitlePlugin.prototype._proceedSorting = function (hitObj) {
32716
32772
  if (this._canClickToSort(hitObj)) {
32717
32773
  var colIndex = hitObj["colIndex"];
32718
32774
  // _proceedSorting() method is always produced by user clicking at the header // Thus, this operation is guaranteed to be a user action
32719
- var state = this._prepareSorting(colIndex);
32720
- if (state) {
32721
- this._sortColumn([state], { "isUserAction": true });
32722
- }
32775
+ this.sortColumn(colIndex, null, { "isUserAction": true });
32776
+
32723
32777
  var grid = hitObj["grid"];
32724
32778
  if(grid && grid["focus"]) {
32725
32779
  grid["focus"]();
@@ -32729,7 +32783,7 @@ SortableTitlePlugin.prototype._proceedSorting = function (hitObj) {
32729
32783
  var ce = {};
32730
32784
  ce["colIndex"] = colIndex;
32731
32785
  ce["sortOrder"] = this.getSortOrder(colIndex);
32732
- ce["dataColumnName"] = this.getColumnSortingField(colIndex);
32786
+ ce["dataColumnName"] = this.getColumnSortingField(colIndex); // This should be deprecated
32733
32787
  this._dispatch("clicked", ce);
32734
32788
  }
32735
32789
  }
@@ -32919,7 +32973,7 @@ SortableTitlePlugin.prototype.sortSeparators = function (comparer) {
32919
32973
  var sortStateCount = this._sortStates.length;
32920
32974
  var rowDefField = SortableTitlePlugin._toRowDefField();
32921
32975
  for(var i = 0; i < sortStateCount; i++){
32922
- var sortState = this._sortStates[i];
32976
+ var sortState = this._sortStates[i];
32923
32977
  var field = this._rowDefMode ? rowDefField : sortState["field"];
32924
32978
  sortOrders.push(sortState["sortOrder"]);
32925
32979
  sortFields.push(field);
@@ -32930,19 +32984,51 @@ SortableTitlePlugin.prototype.sortSeparators = function (comparer) {
32930
32984
 
32931
32985
 
32932
32986
  /** @private
32933
- * @param {number|string} colRef Column index or field
32987
+ * @param {(number|string|SortableTitlePlugin.SortingDefinition)} sortingDef This could be column index, field, or SortingDefinition
32934
32988
  * @param {string=} sortOrder "a" for ascending, "d" for descending, and "n" for no sorting
32935
32989
  * @returns {Object} state Returns null, if nothing is changed
32936
32990
  */
32937
- SortableTitlePlugin.prototype._prepareSorting = function (colRef, sortOrder) {
32991
+ SortableTitlePlugin.prototype._prepareSorting = function (sortingDef, sortOrder) {
32938
32992
  if (!this._maxCount) {
32939
32993
  return null;
32940
32994
  }
32995
+ var host = this._hosts[0];
32996
+ if(!host) {
32997
+ return null;
32998
+ }
32941
32999
 
32942
- var colIndex = this._getColumnIndex(colRef);
32943
- var priority = this.getSortPriority(colIndex);
32944
- var field = this.getColumnSortingField(colIndex);
33000
+ var colIndex = -1;
33001
+ var colRef = "";
33002
+ if(typeof sortingDef === "number") {
33003
+ colIndex = sortingDef;
33004
+ } else if(typeof sortingDef === "string") { // This would be either column id or field
33005
+ colRef = sortingDef;
33006
+ colIndex = this._getColumnIndex(colRef);
33007
+ } else if(sortingDef && typeof sortingDef === "object") {
33008
+ colRef = sortingDef["colId"] || sortingDef["field"];
33009
+ if(colRef) {
33010
+ colIndex = this._getColumnIndex(colRef);
33011
+ } else if(typeof sortingDef["colIndex"] === "number") {
33012
+ colIndex = sortingDef["colIndex"];
33013
+ }
33014
+ if(!sortOrder) {
33015
+ sortOrder = sortingDef["sortOrder"] || sortingDef["order"] || null;
33016
+ }
33017
+ }
33018
+
33019
+ var field = "";
33020
+ var sortLogic = null;
33021
+ if(colIndex >= 0) {
33022
+ field = this.getColumnSortingField(colIndex);
33023
+ var sortOptions = this._getSortOptions(colIndex);
33024
+ if(sortOptions) {
33025
+ sortLogic = sortOptions["sortLogic"];
33026
+ }
33027
+ } else if(colRef) {
33028
+ field = colRef; // Assume that colRef is a field and not a column id
33029
+ }
32945
33030
 
33031
+ var priority = this.getSortPriority(colIndex, field);
32946
33032
  var curState = (priority >= 0) ? this._sortStates[priority] : null;
32947
33033
  var curOrder = curState ? curState["sortOrder"] : "n";
32948
33034
 
@@ -32970,7 +33056,6 @@ SortableTitlePlugin.prototype._prepareSorting = function (colRef, sortOrder) {
32970
33056
 
32971
33057
  this._sortStates.splice(priority, 1); // Remove sort states
32972
33058
  this._clearSortSymbols(curState); // Clear any previous symbols
32973
- // TODO: Other states in curState should be cleared as it is actually a sortOptions object
32974
33059
  }
32975
33060
 
32976
33061
  if (nextOrder === "a" || nextOrder === "d") { // Reorder sort states
@@ -32978,12 +33063,14 @@ SortableTitlePlugin.prototype._prepareSorting = function (colRef, sortOrder) {
32978
33063
  return null;
32979
33064
  }
32980
33065
  if (!curState) {
32981
- // TODO: Sort state object should not be sortOptions
32982
- curState = this._newSortOptions(colIndex); // This may come with sortLogic
32983
- }
32984
- if(colIndex < 0) {
32985
- curState["field"] = field;
33066
+ curState = {};
33067
+ var colId = host.getColumnId(colIndex);
33068
+ if(colId) {
33069
+ curState["colId"] = colId;
33070
+ }
32986
33071
  }
33072
+ curState["field"] = field;
33073
+ curState["sortLogic"] = sortLogic || null;
32987
33074
 
32988
33075
  this._sortStates.push(curState); // Latest sorting have lowest priority (multiColumn sorting)
32989
33076
  }
@@ -33018,31 +33105,47 @@ SortableTitlePlugin.prototype._prepareSorting = function (colRef, sortOrder) {
33018
33105
  };
33019
33106
 
33020
33107
  /** @private
33021
- * @param {Array.<Object>} states States from _prepareSorting for dispatching columnSorted event.
33108
+ * @param {Object|Array.<Object>} states States from _prepareSorting for dispatching columnSorted event.
33022
33109
  * @param {Object=} opt_arg Event argument to be sent with preDataSorting event
33023
33110
  * @fires SortableTitlePlugin#preDataSorting
33024
33111
  * @fires SortableTitlePlugin#columnSorted
33025
33112
  */
33026
33113
  SortableTitlePlugin.prototype._sortColumn = function (states, opt_arg) {
33114
+ if(!states) {
33115
+ return;
33116
+ }
33117
+
33027
33118
  this._sortDataView(opt_arg); // Update Data
33028
33119
  this.updateSortSymbols(); // Update Display
33029
33120
 
33030
- var res = states[0] || {};
33031
- var len = states.length;
33032
- if (len > 1) {
33033
- res["colIndices"] = new Array(len);
33034
- res["sortedFields"] = new Array(len);
33035
- res["sortOrders"] = new Array(len);
33036
- res["prevOrders"] = new Array(len);
33037
- for (var i = 0; i < len; i++) {
33038
- var obj = states[i];
33039
- res["colIndices"][i] = obj["colIndex"];
33040
- res["sortedFields"][i] = obj["sortedField"];
33041
- res["sortOrders"][i] = obj["sortOrder"];
33042
- res["prevOrders"][i] = obj["prevOrder"];
33121
+ var evtArg = null;
33122
+ if(Array.isArray(states)) {
33123
+ var len = states.length;
33124
+ for(var i = 0; i < len; ++i) {
33125
+ var state = states[i];
33126
+ if(state) {
33127
+ if(evtArg) {
33128
+ if(!evtArg["colIndices"]) {
33129
+ evtArg["colIndices"] = [];
33130
+ evtArg["sortedFields"] = [];
33131
+ evtArg["sortOrders"] = [];
33132
+ evtArg["prevOrders"] = [];
33133
+ }
33134
+
33135
+ evtArg["colIndices"].push(state["colIndex"]);
33136
+ evtArg["sortedFields"].push(state["sortedField"]);
33137
+ evtArg["sortOrders"].push(state["sortOrder"]);
33138
+ evtArg["prevOrders"].push(state["prevOrder"]);
33139
+ } else {
33140
+ evtArg = state;
33141
+ }
33142
+ }
33043
33143
  }
33144
+ evtArg = states[0];
33145
+ } else {
33146
+ evtArg = states;
33044
33147
  }
33045
- this._dispatch("columnSorted", res);
33148
+ this._dispatch("columnSorted", evtArg);
33046
33149
  };
33047
33150
 
33048
33151
  /** @private
@@ -33100,24 +33203,23 @@ SortableTitlePlugin.prototype._onColumnAdded = function (e) {
33100
33203
  * @fires SortableTitlePlugin#columnSorted
33101
33204
  */
33102
33205
  SortableTitlePlugin.prototype._onColumnRemoved = function (e) {
33103
- if (!e["atTheMiddle"]) { return; }
33104
-
33105
33206
  var sortCount = this._sortStates.length;
33106
33207
  if (!sortCount) {
33107
33208
  return;
33108
33209
  }
33109
- var colData = e["columnData"];
33110
- var sortOptions = colData ? colData["sortableTitle"] : null;
33111
- var sortOrder = sortOptions ? sortOptions["sortOrder"] : "";
33112
-
33113
- // TODO: columnRemoved event could be fired repeatedly and triggers multiple sorts
33114
- if (sortOrder) {
33115
- var priority = this._sortStates.indexOf(sortOptions);
33116
- if (priority >= 0) {
33117
- this._sortStates.splice(priority, 1);
33210
+ var colId = e["colId"];
33211
+ if (!colId) {
33212
+ return;
33213
+ }
33214
+ // WARNING: columnRemoved event could be fired repeatedly. Sorting could be triggered multiple times
33215
+ for(var i = 0; i < sortCount; ++i) {
33216
+ var sortState = this._sortStates[i];
33217
+ if (sortState["colId"] === colId) {
33218
+ this._sortStates.splice(i, 1);
33219
+ this._clearSortSymbols(sortState);
33220
+ this._sortDataView();
33221
+ break;
33118
33222
  }
33119
- this._clearSortSymbols(sortOptions);
33120
- this._sortDataView();
33121
33223
  }
33122
33224
  };
33123
33225
 
@@ -33211,8 +33313,8 @@ SortableTitlePlugin.prototype._updateSortableIndicator = function (hostIndex) {
33211
33313
 
33212
33314
  var section = host.getSection("title");
33213
33315
  if (section == null) { return; }
33214
- var sectionCount = section["getColumnCount"]();
33215
- for (var col = sectionCount; --col >= 0;) {
33316
+ var colCount = section["getColumnCount"]();
33317
+ for (var col = colCount; --col >= 0;) {
33216
33318
 
33217
33319
  var rowCount = section["getRowCount"]();
33218
33320
  for (var r = 0; r < rowCount; r++) {
@@ -33306,35 +33408,24 @@ SortableTitlePlugin.prototype._createIconElem = function (icon, fallback) {
33306
33408
  };
33307
33409
 
33308
33410
  /** @private
33309
- * @param {Object} sortOptions
33411
+ * @param {string|number|Object} colRef This can be sortState, column id, column field, or column index
33310
33412
  * @return {number}
33311
33413
  */
33312
- SortableTitlePlugin.prototype._getColumnIndexByOptions = function (sortOptions) {
33313
- if(sortOptions) {
33414
+ SortableTitlePlugin.prototype._getColumnIndex = function (colRef) {
33415
+ if(colRef != null) {
33314
33416
  var host = this._hosts[0];
33315
- var colCount = host ? host.getColumnCount() : 0;
33316
- for (var c = 0; c < colCount; ++c) {
33317
- var colData = host.getColumnData(c); // Equivalent to _getSortOptions() method
33318
- if (colData) {
33319
- if(sortOptions === colData["sortableTitle"]) {
33320
- return c;
33321
- }
33417
+ if(host) {
33418
+ if(typeof colRef === "number") {
33419
+ return colRef;
33420
+ } else if(typeof colRef === "string") {
33421
+ return host.getColumnIndex(colRef);
33422
+ } else {
33423
+ return host.getColumnIndex(colRef["colId"]);
33322
33424
  }
33323
33425
  }
33324
33426
  }
33325
33427
  return -1;
33326
33428
  };
33327
- /** @private
33328
- * @param {string|number} colRef
33329
- * @return {number}
33330
- */
33331
- SortableTitlePlugin.prototype._getColumnIndex = function (colRef) {
33332
- var host = this._hosts[0];
33333
- if(host && colRef != null) {
33334
- return host.getColumnIndex(colRef);
33335
- }
33336
- return -1;
33337
- };
33338
33429
 
33339
33430
  /** @private
33340
33431
  * @param {string|number} colRef
@@ -33355,10 +33446,7 @@ SortableTitlePlugin.prototype._getColumnId = function (colRef) {
33355
33446
  SortableTitlePlugin.prototype._getSortOptions = function (colIndex) {
33356
33447
  var host = this._hosts[0];
33357
33448
  if (host) {
33358
- var colData = host.getColumnData(colIndex);
33359
- if (colData) {
33360
- return colData["sortableTitle"];
33361
- }
33449
+ return host.getColumnData(colIndex)["sortableTitle"] || null;
33362
33450
  }
33363
33451
  return null;
33364
33452
  };