@refinitiv-ui/efx-grid 6.0.116 → 6.0.118

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. package/lib/core/dist/core.js +214 -42
  2. package/lib/core/dist/core.min.js +1 -1
  3. package/lib/core/es6/grid/Core.js +9 -2
  4. package/lib/grid/index.js +1 -1
  5. package/lib/grid/themes/halo/dark/efx-grid.js +1 -1
  6. package/lib/grid/themes/halo/dark/es5/all-elements.js +1 -1
  7. package/lib/grid/themes/halo/light/efx-grid.js +1 -1
  8. package/lib/grid/themes/halo/light/es5/all-elements.js +1 -1
  9. package/lib/grid/themes/solar/charcoal/efx-grid.js +1 -1
  10. package/lib/grid/themes/solar/charcoal/es5/all-elements.js +1 -1
  11. package/lib/grid/themes/solar/pearl/efx-grid.js +1 -1
  12. package/lib/grid/themes/solar/pearl/es5/all-elements.js +1 -1
  13. package/lib/row-segmenting/es6/RowSegmenting.js +74 -29
  14. package/lib/rt-grid/dist/rt-grid.js +324 -141
  15. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  16. package/lib/rt-grid/es6/ColumnDefinition.js +5 -2
  17. package/lib/rt-grid/es6/DataConnector.d.ts +2 -0
  18. package/lib/rt-grid/es6/DataConnector.js +8 -0
  19. package/lib/rt-grid/es6/Grid.d.ts +4 -0
  20. package/lib/rt-grid/es6/Grid.js +39 -1
  21. package/lib/rt-grid/es6/ReferenceCounter.d.ts +2 -0
  22. package/lib/rt-grid/es6/ReferenceCounter.js +10 -0
  23. package/lib/rt-grid/es6/RowDefinition.js +28 -34
  24. package/lib/tr-grid-auto-tooltip/es6/AutoTooltip.d.ts +1 -0
  25. package/lib/tr-grid-auto-tooltip/es6/AutoTooltip.js +200 -26
  26. package/lib/tr-grid-contextmenu/es6/ContextMenu.js +11 -0
  27. package/lib/tr-grid-contextmenu/es6/MenuEventAPI.d.ts +1 -1
  28. package/lib/tr-grid-contextmenu/es6/MenuEventAPI.js +13 -8
  29. package/lib/tr-grid-contextmenu/es6/MenuItem.d.ts +3 -1
  30. package/lib/tr-grid-contextmenu/es6/MenuItem.js +75 -35
  31. package/lib/tr-grid-contextmenu/es6/PopupMenu.d.ts +5 -1
  32. package/lib/tr-grid-contextmenu/es6/PopupMenu.js +70 -59
  33. package/lib/tr-grid-in-cell-editing/es6/InCellEditing.d.ts +3 -0
  34. package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +115 -28
  35. package/lib/tr-grid-util/es6/GroupDefinitions.js +1 -1
  36. package/lib/types/es6/InCellEditing.d.ts +3 -0
  37. package/lib/types/es6/MenuEventAPI.d.ts +1 -1
  38. package/lib/types/es6/MenuItem.d.ts +3 -1
  39. package/lib/types/es6/PopupMenu.d.ts +5 -1
  40. package/lib/types/es6/RealtimeGrid/DataConnector.d.ts +2 -0
  41. package/lib/types/es6/RealtimeGrid/Grid.d.ts +4 -0
  42. package/lib/types/es6/RealtimeGrid/ReferenceCounter.d.ts +2 -0
  43. package/lib/versions.json +5 -5
  44. package/package.json +2 -2
@@ -337,9 +337,12 @@ ColumnDefinition.prototype.initialize = function(columnOption) {
337
337
 
338
338
  this._setField(field, columnOption); // Perform some field manipulation
339
339
 
340
- val = columnOption["name"] || columnOption["title"]; // title is migrated from Composite Grid
340
+ val = columnOption["name"];
341
+ if(val == null) {
342
+ val = columnOption["title"]; // For backward compatability
343
+ }
341
344
  if(val != null) { // Name can be empty string
342
- this._name = val;
345
+ this._name = (typeof val === "string") ? val : (val + "");
343
346
  this._defaultName = false;
344
347
  }
345
348
 
@@ -11,6 +11,8 @@ declare class DataConnector extends EventDispatcher {
11
11
 
12
12
  public getAllRics(): (string)[]|null;
13
13
 
14
+ public hasRic(): boolean;
15
+
14
16
  public getAllRowDefs(): (RowDefinition)[]|null;
15
17
 
16
18
  public getAllFields(): (string)[];
@@ -53,6 +53,14 @@ DataConnector.prototype.getAllRics = function () {
53
53
  return this._rics.getAllReferences();
54
54
  };
55
55
 
56
+ /**
57
+ * @public
58
+ * @returns {boolean}
59
+ */
60
+ DataConnector.prototype.hasRic = function () {
61
+ return this._rics.hasReference();
62
+ };
63
+
56
64
  /** @public
57
65
  * @returns {Array.<RowDefinition>}
58
66
  */
@@ -256,6 +256,8 @@ declare class Grid extends EventDispatcher {
256
256
 
257
257
  public getAllRics(): (string)[]|null;
258
258
 
259
+ public hasRic(): boolean;
260
+
259
261
  public setRowData(rowRef: Grid.RowReference|null, values: any): void;
260
262
 
261
263
  public setStaticRowData(rowRef: Grid.RowReference|null, values: any): void;
@@ -296,6 +298,8 @@ declare class Grid extends EventDispatcher {
296
298
 
297
299
  public clearSort(): void;
298
300
 
301
+ public getSortingStates(): (any)[];
302
+
299
303
  public getDataView(): DataView|null;
300
304
 
301
305
  public setPage(pageIndex: number): boolean;
@@ -600,6 +600,12 @@ Grid.prototype._focusingArgs = null;
600
600
  * @private
601
601
  */
602
602
  Grid.prototype._scrolledRow = -1;
603
+ /** @type {boolean}
604
+ * @private
605
+ */
606
+ Grid.prototype._unlinking = false;
607
+
608
+
603
609
  /** @public
604
610
  */
605
611
  Grid.prototype.dispose = function() {
@@ -2770,7 +2776,9 @@ Grid.prototype.unlinkChain = function(rowRef) {
2770
2776
  return;
2771
2777
  }
2772
2778
 
2779
+ this._unlinking = true;
2773
2780
  rowDef.unlinkChain();
2781
+ this._unlinking = false;
2774
2782
  };
2775
2783
 
2776
2784
  /** Alias to setRic
@@ -3076,6 +3084,14 @@ Grid.prototype.setRicData = function(ric, values) {
3076
3084
  Grid.prototype.getAllRics = function() {
3077
3085
  return this._connector.getAllRics();
3078
3086
  };
3087
+
3088
+ /** Returns true if there is at least 1 RIC in the grid. This method includes RICs not in the row.
3089
+ * @public
3090
+ * @return {boolean}
3091
+ */
3092
+ Grid.prototype.hasRic = function() {
3093
+ return this._connector.hasRic();
3094
+ };
3079
3095
  /** A shorthand to set row data based on index of the specified row. It is better to keep rowDefinition object for updating data directly as row index can be changed by sorting and filtering.
3080
3096
  * @public
3081
3097
  * @param {Grid~RowReference} rowRef
@@ -3459,6 +3475,28 @@ Grid.prototype.getSortOrder = function() {
3459
3475
  Grid.prototype.clearSort = function() {
3460
3476
  this._stp.clearSortState(); // WARNING: No event is dispatched
3461
3477
  };
3478
+ /** Get sorting states from sorting columns
3479
+ * @public
3480
+ * @return {!Array.<Object>} Array of sorting states ordered by priority. If there is no sorting column, an empty array is returned
3481
+ */
3482
+ Grid.prototype.getSortingStates = function () { // This method is mainly for backward compatability
3483
+ let ary = [];
3484
+ let states = this._stp.getSortingStates();
3485
+ let stateCount = states.length;
3486
+
3487
+ for (let i = 0; i < stateCount; i++) {
3488
+ let state = states[i];
3489
+ let colIndex = this._stp.getSortedColumnIndex(i);
3490
+
3491
+ ary.push({
3492
+ "colId": this.getColumnId(colIndex),
3493
+ "colIndex": colIndex,
3494
+ "order": state["sortOrder"]
3495
+ });
3496
+ }
3497
+
3498
+ return ary;
3499
+ };
3462
3500
 
3463
3501
  /**
3464
3502
  * @private
@@ -3478,7 +3516,7 @@ Grid.prototype._onQuote2PostUpdate = function (e) {
3478
3516
  */
3479
3517
  Grid.prototype._onDataChanged = function(e) {
3480
3518
  let rowData = e["rowData"]; // Use rowData to retrieve corresponding subscription object
3481
- if (!rowData) {
3519
+ if (!rowData || this._unlinking) {
3482
3520
  return; // This must be a global change
3483
3521
  }
3484
3522
  let rowDef = rowData[ROW_DEF];
@@ -10,6 +10,8 @@ declare class ReferenceCounter {
10
10
 
11
11
  public getAllReferences(): (string)[];
12
12
 
13
+ public hasReference(): boolean;
14
+
13
15
  public getAllReferers(): (string)[];
14
16
 
15
17
  public getAllReferrers(): (string)[];
@@ -40,6 +40,16 @@ ReferenceCounter.prototype.getAllReferences = function() {
40
40
  return Object.keys(this._counter);
41
41
  };
42
42
 
43
+ /** @public
44
+ * @return {boolean}
45
+ */
46
+ ReferenceCounter.prototype.hasReference = function() {
47
+ for (const key in this._counter) {
48
+ return true;
49
+ }
50
+ return false;
51
+ };
52
+
43
53
  /** @public
44
54
  * @return {!Array.<string>}
45
55
  */
@@ -12,7 +12,7 @@ import { DataTable } from "../../core/es6/data/DataTable.js";
12
12
  * @property {Array.<string>=} fields=null Field that corresponds to the given static values
13
13
  * @property {boolean=} asChain=false The given ric will be treated as a chain
14
14
  * @property {string=} chainRic="" RIC to be used for chain request (overiding ric property)
15
- * @property {boolean=} collapsed=true Chain or segment is collapsed by default
15
+ * @property {boolean=} collapsed Chain is collapsed by default. Segment is expanded by default.
16
16
  * @property {(string|null)=} label=null
17
17
  * @property {boolean=} hidden=true When this row is hidden
18
18
  * @property {boolean=} realTime=true Realtime row, able to request for JET/RTK
@@ -139,7 +139,7 @@ RowDefinition.prototype._subId = "";
139
139
  /** @type {boolean|null}
140
140
  * @private
141
141
  */
142
- RowDefinition.prototype._expanded = null;
142
+ RowDefinition.prototype._collapsed = null;
143
143
  /** @type {boolean}
144
144
  * @private
145
145
  */
@@ -271,17 +271,15 @@ RowDefinition.prototype.initialize = function(rowOptions) {
271
271
  this._realTime = val;
272
272
  }
273
273
 
274
- val = rowOptions["collapsed"];
275
- let collapsed = extractedOptions["collapsed"];
276
- if(val != null || !collapsed){
277
- this._expanded = !collapsed;
278
- }
279
-
280
274
  val = rowOptions["asSegment"];
281
275
  if(val != null) {
282
276
  this._asSegment = val ? true : false;
283
277
  }
284
278
 
279
+ if(this._isChain) {
280
+ this._collapsed = extractedOptions["collapsed"]; // Temporary state
281
+ }
282
+
285
283
  val = rowOptions["keepModel"];
286
284
  if(val) {
287
285
  this._userModel = rowOptions;
@@ -403,12 +401,11 @@ RowDefinition.prototype.setContent = function(userInput, extractedOptions) {
403
401
  this.resetUpdates(); // Remove all previous data updates because a new content is just entered
404
402
 
405
403
  this._userInput = userInput;
404
+ let collapsed = extractedOptions["collapsed"];
406
405
  if(realtimeRow) {
407
- let expanded = !extractedOptions["collapsed"];
408
406
  let chainRic = extractedOptions["chainRic"];
409
407
  if(asChain === true){
410
- this._ric = expanded === false ? userInput : userInput.replace("0#", "");
411
- this._expanded = expanded; // Only chain can be expanded by 0#
408
+ this._ric = collapsed === true ? userInput : userInput.replace("0#", "");
412
409
  } else {
413
410
  this._ric = userInput;
414
411
  }
@@ -435,15 +432,12 @@ RowDefinition.prototype.setContent = function(userInput, extractedOptions) {
435
432
  if(this._isChain) {
436
433
  dv.setSegmentSeparator(this._rowId, true);
437
434
  }
438
- if(this.isChainCollapsed()) {
439
- if(this._expanded){
440
- this.expandChain();
441
- }
442
- } else {
443
- if (!this._expanded) {
444
- this.collapseChain();
445
- }
435
+
436
+ if(collapsed !== this.isChainCollapsed()) {
437
+ dv.collapseSegment(this._rowId, collapsed);
446
438
  }
439
+ this._collapsed = null;
440
+
447
441
  _stallSorting(dv, false, stalledSorting);
448
442
  if(segmentId) { // If data id is changed and the row is a child of a segment, then segment child data id must be updated
449
443
  dv.addSegmentChild(segmentId, this._rowId, this._dataId);
@@ -519,9 +513,9 @@ RowDefinition.prototype.getConfigObject = function(rowOptions) {
519
513
  obj["asChain"] = val;
520
514
  }
521
515
 
522
- val = this._expanded;
516
+ val = this._collapsed;
523
517
  if(val != null) {
524
- obj["collapsed"] = !val;
518
+ obj["collapsed"] = val;
525
519
  }
526
520
 
527
521
  // check row hidden
@@ -1029,8 +1023,9 @@ RowDefinition.prototype.registerToView = function(view, rowId) {
1029
1023
  if(isSegment) {
1030
1024
  view.setSegmentSeparator(newRowId);
1031
1025
  _stallSorting(view, false, stalledSorting);
1032
- if(!this._expanded) {
1033
- view.collapseSegment(newRowId);
1026
+ if(this._collapsed != null) {
1027
+ view.collapseSegment(newRowId, this._collapsed);
1028
+ this._collapsed = null;
1034
1029
  }
1035
1030
  } else if(!this._parent && parentRowId) { // Constituent cannot be added to another segment
1036
1031
  view.addSegmentChild(parentRowId, newRowId, this._dataId);
@@ -1148,23 +1143,22 @@ RowDefinition.prototype._toRealTimeRow = function() {
1148
1143
  if(!this._ric) { // Empty row
1149
1144
  return;
1150
1145
  }
1151
- if(this.isRowHeader()) {
1152
- return;
1146
+ if(this.isRowHeader() || !this._parent) {
1147
+ return; // If the row is already a normal row or row header, it cannot be converted
1153
1148
  }
1154
1149
 
1155
- this._realTimeField = true;
1150
+ this._realTime = true;
1151
+ this._dc.setRowData(this._dataId, null); // Remove existing data. WARNING: Trigger data update immediately
1156
1152
  this._dataId = this._rowId + this._ric; // JET/RTK will generate data id to be rowId (given from this rowDef) + ric;
1157
1153
 
1158
1154
  this._autoGenerated = false;
1159
1155
  this._parent = null;
1160
1156
  this._depthLevel = 0;
1161
1157
 
1162
- // Add static value to the new allocated row
1163
- if(this._staticValues) {
1158
+ this.subscribeForUpdates();
1159
+ if(this._staticValues) { // Add static value to the new allocated row
1164
1160
  this.setRowData(this._staticValues);
1165
1161
  }
1166
-
1167
- this.subscribeForUpdates();
1168
1162
  };
1169
1163
 
1170
1164
  /** @public
@@ -1198,7 +1192,7 @@ RowDefinition.prototype.unlinkChain = function() {
1198
1192
  view.setSegmentSeparator(rid, false);
1199
1193
  }
1200
1194
 
1201
- this._isChain = this._expanded = false;
1195
+ this._isChain = false;
1202
1196
  this._chainRic = "";
1203
1197
  this._userInput = this._ric;
1204
1198
  this._children = null;
@@ -1211,7 +1205,6 @@ RowDefinition.prototype.unlinkChain = function() {
1211
1205
  */
1212
1206
  RowDefinition.prototype.collapseChain = function() {
1213
1207
  if(this._isChain && this._view) {
1214
- this._expanded = false;
1215
1208
  return this._view.collapseSegment(this._rowId, true);
1216
1209
  }
1217
1210
  return false;
@@ -1227,7 +1220,6 @@ RowDefinition.prototype.collapseChain = function() {
1227
1220
  */
1228
1221
  RowDefinition.prototype.expandChain = function() {
1229
1222
  if(this._isChain && this._view) {
1230
- this._expanded = true;
1231
1223
  return this._view.collapseSegment(this._rowId, false);
1232
1224
  }
1233
1225
  return false;
@@ -1240,7 +1232,7 @@ RowDefinition.prototype.expandChain = function() {
1240
1232
  * @return {boolean} Returns true if there is a change in view
1241
1233
  */
1242
1234
  RowDefinition.prototype.toggleChain = function() {
1243
- if(this._expanded) {
1235
+ if(this.isChainExpanded()) {
1244
1236
  return this.collapseChain();
1245
1237
  } else {
1246
1238
  return this.expandChain();
@@ -1421,6 +1413,8 @@ RowDefinition.extractRowOptions = function(rowOptions) {
1421
1413
  asChain = true;
1422
1414
  }
1423
1415
  expanded = true;
1416
+ } else if(asChain) {
1417
+ expanded = false;
1424
1418
  }
1425
1419
 
1426
1420
  let extractedOptions = {};
@@ -1,5 +1,6 @@
1
1
  import { Ext } from "../../tr-grid-util/es6/Ext.js";
2
2
  import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
3
+ import { Conflator } from "../../tr-grid-util/es6/Conflator.js";
3
4
 
4
5
  declare namespace AutoTooltipPlugin {
5
6
 
@@ -1,5 +1,6 @@
1
1
  import { Ext } from "../../tr-grid-util/es6/Ext.js";
2
2
  import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
3
+ import { Conflator } from "../../tr-grid-util/es6/Conflator.js";
3
4
 
4
5
  var isSafari = navigator.vendor &&
5
6
  navigator.vendor.indexOf('Apple') > -1 &&
@@ -26,11 +27,20 @@ var isSafari = navigator.vendor &&
26
27
  * @extends {GridPlugin}
27
28
  */
28
29
  var AutoTooltipPlugin = function (options) {
29
- this.requestTooltipUpdate = this.requestTooltipUpdate.bind(this);
30
30
  this.applyTooltipToAllColumns = this.applyTooltipToAllColumns.bind(this);
31
31
  this._onPreSectionDataBinding = this._onPreSectionDataBinding.bind(this);
32
+ this._onPostSectionDataBinding = this._onPostSectionDataBinding.bind(this);
32
33
  this._onColumnAdded = this._onColumnAdded.bind(this);
33
34
 
35
+ this._requestNonContentSectionUpdate = this._requestNonContentSectionUpdate.bind(this);
36
+ this._nonContentSectionUpdateConflator = new Conflator(300, this._requestNonContentSectionUpdate);
37
+
38
+ this._requestContentSectionUpdate = this._requestContentSectionUpdate.bind(this);
39
+ this._contentSectionUpdateConflator = new Conflator(300, this._requestContentSectionUpdate);
40
+
41
+ this.requestTooltipUpdate = this.requestTooltipUpdate.bind(this);
42
+ this._tooltipUpdateConflator = new Conflator(300, this.requestTooltipUpdate);
43
+
34
44
  this._hosts = [];
35
45
 
36
46
  if (options) {
@@ -39,6 +49,39 @@ var AutoTooltipPlugin = function (options) {
39
49
  };
40
50
  Ext.inherits(AutoTooltipPlugin, GridPlugin);
41
51
 
52
+ /** @private
53
+ * @param {Object} column
54
+ * @return {boolean}
55
+ */
56
+ AutoTooltipPlugin._isColumnVisible = function(column) {
57
+ if(!column) {
58
+ return false;
59
+ }
60
+
61
+ if(column.getVisibility && !column.getVisibility()) {
62
+ return false;
63
+ }
64
+
65
+ var colElem = column.getElement();
66
+ if(!colElem) {
67
+ return false;
68
+ }
69
+
70
+ return true;
71
+ };
72
+
73
+ /** @private
74
+ * @param {Array.<Object>} hosts
75
+ * @return {boolean}
76
+ */
77
+ AutoTooltipPlugin._isUpdateRequired = function(hosts) {
78
+ var len = hosts.length;
79
+ if(len <= 0 || isSafari) {
80
+ return false;
81
+ }
82
+ return true;
83
+ };
84
+
42
85
  /** If true, include title sections into the calculation
43
86
  * @type {boolean}
44
87
  * @private
@@ -63,6 +106,11 @@ AutoTooltipPlugin.prototype._applyTimer = 0;
63
106
  */
64
107
  AutoTooltipPlugin.prototype._calcDelay = 300;
65
108
 
109
+ /** @type {boolean}
110
+ * @private
111
+ */
112
+ AutoTooltipPlugin.prototype._nonContentSectionUpdated = false;
113
+
66
114
  /** @public
67
115
  * @return {string}
68
116
  */
@@ -87,12 +135,12 @@ AutoTooltipPlugin.prototype.initialize = function (host, options) {
87
135
  return;
88
136
  }
89
137
  host.listen("preSectionDataBinding", this._onPreSectionDataBinding);
90
- host.listen("postSectionDataBinding", this.requestTooltipUpdate);
138
+ host.listen("postSectionDataBinding", this._onPostSectionDataBinding);
91
139
  host.listen("widthChanged", this.requestTooltipUpdate);
92
140
  host.listen("columnAdded", this._onColumnAdded);
93
141
 
94
142
  // In case of lazy loading
95
- this.requestTooltipUpdate();
143
+ this._requestAllSectionsUpdate();
96
144
  };
97
145
 
98
146
  /** @public
@@ -104,15 +152,13 @@ AutoTooltipPlugin.prototype.unload = function (host) {
104
152
  this._hosts.splice(at, 1);
105
153
 
106
154
  host.unlisten("preSectionDataBinding", this._onPreSectionDataBinding);
107
- host.unlisten("postSectionDataBinding", this.requestTooltipUpdate);
155
+ host.unlisten("postSectionDataBinding", this._onPostSectionDataBinding);
108
156
  host.unlisten("widthChanged", this.requestTooltipUpdate);
109
157
  host.unlisten("columnAdded", this._onColumnAdded);
110
158
 
111
159
  if (!this._hosts.length) {
112
- if (this._applyTimer) {
113
- clearTimeout(this._applyTimer);
114
- this._applyTimer = 0;
115
- }
160
+ this._tooltipUpdateConflator.reset();
161
+ this._nonContentSectionUpdateConflator.reset();
116
162
  }
117
163
 
118
164
  this._dispose();
@@ -131,9 +177,9 @@ AutoTooltipPlugin.prototype.config = function (options) {
131
177
  if (val != null) {
132
178
  this._title = val ? true : false;
133
179
  }
134
- var footerVal = extOptions["footer"];
135
- if (footerVal != null) {
136
- this._footer = footerVal ? true : false;
180
+ val = extOptions["footer"];
181
+ if (val != null) {
182
+ this._footer = val ? true : false;
137
183
  }
138
184
  // Enable auto tooltip to all column by default
139
185
  val = extOptions["content"];
@@ -142,7 +188,7 @@ AutoTooltipPlugin.prototype.config = function (options) {
142
188
  }
143
189
  }
144
190
 
145
- // Retrive auto tooltip data from comlum
191
+ // Retrive auto tooltip data from columns
146
192
  var columns = options["columns"];
147
193
  if (columns) {
148
194
  var len = columns.length;
@@ -217,28 +263,28 @@ AutoTooltipPlugin.prototype._configColumn = function(colIndex, columnConfig) {
217
263
  * @param {number=} toR End row index
218
264
  */
219
265
  AutoTooltipPlugin.prototype.applyTooltip = function (colIndex, fromR, toR) {
220
- var len = this._hosts.length;
221
- if (len <= 0 || isSafari) {
266
+ var hosts = this._hosts;
267
+ if(!AutoTooltipPlugin._isUpdateRequired(hosts)) {
222
268
  return;
223
269
  }
224
270
 
225
- for (var i = 0; i < len; ++i) {
271
+ for (var i = 0; i < hosts.length; ++i) {
226
272
  var host = this._hosts[i];
227
273
  if (this._title) {
228
274
  var titles = host.getAllSections("title");
229
275
  for (var t = titles.length; --t >= 0;) {
230
- this._applyTooltipToSection(titles[t], colIndex);
276
+ this._updateNonContentSection(titles[t], colIndex);
231
277
  }
232
278
  }
233
279
  if (this._footer) {
234
280
  var footers = host.getAllSections("footer");
235
281
  for (var j = footers.length; --j >= 0;) {
236
- this._applyTooltipToSection(footers[j], colIndex);
282
+ this._updateNonContentSection(footers[j], colIndex);
237
283
  }
238
284
  }
239
285
 
240
286
  if(this._isTooltipCandidate(colIndex)) {
241
- this._applyTooltipToSection(host.getSection("content"), colIndex, fromR, toR);
287
+ this._updateContentSection(host.getSection("content"), colIndex, fromR, toR);
242
288
  }
243
289
  }
244
290
  };
@@ -268,6 +314,135 @@ AutoTooltipPlugin.prototype.applyTooltipToAllColumns = function () {
268
314
  }
269
315
  };
270
316
 
317
+ /** This is similar applyTooltipToColumns() method, but it consolidate multiple requests into one for better performance
318
+ * @public
319
+ */
320
+ AutoTooltipPlugin.prototype.requestTooltipUpdate = function () {
321
+ if(this._tooltipUpdateConflator.conflate()) {
322
+ return;
323
+ }
324
+
325
+ this.applyTooltipToAllColumns();
326
+ };
327
+
328
+ /**
329
+ * @private
330
+ */
331
+ AutoTooltipPlugin.prototype._requestAllSectionsUpdate = function () {
332
+ if(!this._nonContentSectionUpdated) {
333
+ this._requestNonContentSectionUpdate();
334
+ }
335
+
336
+ this._requestContentSectionUpdate();
337
+ };
338
+
339
+ /** @private
340
+ */
341
+ AutoTooltipPlugin.prototype._requestNonContentSectionUpdate = function () {
342
+ if(this._nonContentSectionUpdateConflator.conflate()) {
343
+ return;
344
+ }
345
+
346
+ var hosts = this._hosts;
347
+ if(!AutoTooltipPlugin._isUpdateRequired(hosts)) {
348
+ return;
349
+ }
350
+
351
+ this._nonContentSectionUpdated = true;
352
+
353
+ var colCount = this.getColumnCount();
354
+ var sections, s, c;
355
+ for(var i = 0; i < hosts.length; ++i) {
356
+ var host = hosts[i];
357
+
358
+ sections = host.getAllSections("title");
359
+ for(s = 0; s < sections.length; s++) {
360
+ for(c = 0; c < colCount; c++) {
361
+ this._updateNonContentSection(sections[s], c);
362
+ }
363
+ }
364
+
365
+ sections = host.getAllSections("footer");
366
+ for(s = 0; s < sections.length; s++) {
367
+ for(c = 0; c < colCount; c++) {
368
+ this._updateNonContentSection(sections[s], c);
369
+ }
370
+ }
371
+ }
372
+ };
373
+
374
+
375
+ /** @private
376
+ */
377
+ AutoTooltipPlugin.prototype._requestContentSectionUpdate = function () {
378
+ if(this._contentSectionUpdateConflator.conflate()) {
379
+ return;
380
+ }
381
+
382
+ var hosts = this._hosts;
383
+ if(!AutoTooltipPlugin._isUpdateRequired(hosts)) {
384
+ return;
385
+ }
386
+
387
+ var colCount = this.getColumnCount();
388
+ for(var i = 0; i < hosts.length; ++i) {
389
+ var section = hosts[i].getSection("content");
390
+ for(var c = 0; c < colCount; c++) {
391
+ if(this._isTooltipCandidate(c)) {
392
+ this._updateContentSection(section, c);
393
+ }
394
+ }
395
+ }
396
+ };
397
+
398
+ /**
399
+ * @private
400
+ * @param {Object} section ILayoutGrid
401
+ * @param {number} colIndex Column index
402
+ * @return {boolean} True if there is any change, otherwise false
403
+ */
404
+ AutoTooltipPlugin.prototype._updateNonContentSection = function (section, colIndex) {
405
+ if(!section) { return false; }
406
+
407
+ var column = section.getColumn(colIndex);
408
+ if(!AutoTooltipPlugin._isColumnVisible(column)) {
409
+ return false;
410
+ }
411
+
412
+ var rowCount = section.getRowCount();
413
+ for(var r = 0; r < rowCount; ++r) {
414
+ var cell = section.getCell(colIndex, r, false); // Ignore cell span
415
+ if(!cell || !cell.isVisible()) { return false; }
416
+
417
+ var elem = cell.getContent();
418
+ if(!elem) { return false; }
419
+
420
+ // Set tooltip only if text's length is longer than column width.
421
+ var tooltip = cell.getAttribute("tooltip") || cell.getTooltip();
422
+
423
+ var sw = elem.scrollWidth;
424
+ if(sw && sw > elem.offsetWidth) {
425
+ if(!tooltip) {
426
+ tooltip = cell.getTextContent(); // TODO: Allow custom tooltip text
427
+ cell._autoTooltip = true;
428
+ }
429
+ } else {
430
+ if(cell._autoTooltip) {
431
+ tooltip = "";
432
+ cell._autoTooltip = false;
433
+ }
434
+ }
435
+
436
+ cell.setTooltip(tooltip); // TODO: Avoiding using getter and setter in the same loop
437
+ if(tooltip) {
438
+ cell.setAttribute("ef-title", tooltip); // to make sure ef-title value will actually change
439
+ } else {
440
+ cell.removeAttribute("ef-title");
441
+ }
442
+ }
443
+ return true;
444
+ };
445
+
271
446
  /**
272
447
  * @private
273
448
  * @param {Object} section ILayoutGrid
@@ -276,7 +451,7 @@ AutoTooltipPlugin.prototype.applyTooltipToAllColumns = function () {
276
451
  * @param {number=} toR End row index
277
452
  * @return {boolean} True if there is any change, otherwise false
278
453
  */
279
- AutoTooltipPlugin.prototype._applyTooltipToSection = function (section, colIndex, fromR, toR) {
454
+ AutoTooltipPlugin.prototype._updateContentSection = function (section, colIndex, fromR, toR) {
280
455
  if (!section) { return false; }
281
456
 
282
457
  if (fromR == null) {
@@ -390,7 +565,7 @@ AutoTooltipPlugin.prototype._clearTooltipCache = function (section, colIndex, fr
390
565
  * @param {Event} e event from preSectionDataBinding
391
566
  */
392
567
  AutoTooltipPlugin.prototype._onPreSectionDataBinding = function (e) {
393
- if (e && 'content' === e.sectionType) {
568
+ if (e && e.sectionType === "content") {
394
569
  var colCount = this.getColumnCount();
395
570
  var isDataChange = e.actualUpdate === true;
396
571
  for (var c = 0; c < colCount; ++c) {
@@ -399,13 +574,11 @@ AutoTooltipPlugin.prototype._onPreSectionDataBinding = function (e) {
399
574
  }
400
575
  };
401
576
 
402
- /** This is similar applyTooltipToColumns() method, but it consolidate multiple requests into one for better performance
403
- * @public
577
+ /** @private
578
+ * @param {Event} e event from preSectionDataBinding
404
579
  */
405
- AutoTooltipPlugin.prototype.requestTooltipUpdate = function () {
406
- if (!this._applyTimer) {
407
- this._applyTimer = setTimeout(this.applyTooltipToAllColumns, this._calcDelay);
408
- }
580
+ AutoTooltipPlugin.prototype._onPostSectionDataBinding = function (e) {
581
+ this._requestAllSectionsUpdate();
409
582
  };
410
583
 
411
584
  /** @private
@@ -414,6 +587,7 @@ AutoTooltipPlugin.prototype.requestTooltipUpdate = function () {
414
587
  AutoTooltipPlugin.prototype._onColumnAdded = function(e) {
415
588
  if(e.context && e.colIndex != null) {
416
589
  this._configColumn(e.colIndex, e.context);
590
+ this._nonContentSectionUpdated = false; // Allow title/footer update in postSectionDataBinding
417
591
  }
418
592
  };
419
593