@refinitiv-ui/efx-grid 6.0.87 → 6.0.89
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.js +55 -0
- package/lib/core/dist/core.js +2 -2
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/grid/Core.d.ts +0 -2
- package/lib/core/es6/grid/Core.js +2 -2
- package/lib/grid/index.js +1 -1
- package/lib/row-segmenting/es6/RowSegmenting.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +786 -706
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/ColumnDefinition.js +68 -68
- package/lib/rt-grid/es6/DataConnector.js +26 -26
- package/lib/rt-grid/es6/FieldDefinition.js +27 -27
- package/lib/rt-grid/es6/Grid.js +390 -378
- package/lib/rt-grid/es6/PredefinedFormula.js +1 -1
- package/lib/rt-grid/es6/ReferenceCounter.js +15 -15
- package/lib/rt-grid/es6/RowDefSorter.js +26 -26
- package/lib/rt-grid/es6/RowDefinition.d.ts +5 -6
- package/lib/rt-grid/es6/RowDefinition.js +105 -76
- package/lib/rt-grid/es6/SnapshotFiller.js +77 -77
- package/lib/rt-grid/es6/StyleLoader.js +1 -1
- package/lib/statistics-row/es6/StatisticsRow.d.ts +1 -0
- package/lib/statistics-row/es6/StatisticsRow.js +18 -2
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.d.ts +0 -4
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +2 -2
- package/lib/tr-grid-percent-bar/es6/PercentBar.d.ts +18 -18
- package/lib/tr-grid-percent-bar/es6/PercentBar.js +7 -1
- package/lib/tr-grid-row-filtering/es6/RowFiltering.d.ts +2 -0
- package/lib/tr-grid-row-filtering/es6/RowFiltering.js +69 -18
- package/lib/tr-grid-titlewrap/es6/TitleWrap.d.ts +0 -2
- package/lib/tr-grid-titlewrap/es6/TitleWrap.js +1 -1
- package/lib/tr-grid-util/es6/DragUI.js +2 -1
- package/lib/types/es6/PercentBar.d.ts +18 -18
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +5 -2
- package/lib/types/es6/RowFiltering.d.ts +2 -0
- package/lib/types/es6/StatisticsRow.d.ts +1 -0
- package/lib/versions.json +10 -10
- package/package.json +1 -1
package/lib/rt-grid/es6/Grid.js
CHANGED
@@ -179,13 +179,13 @@ import { ElementWrapper } from "../../core/es6/grid/components/ElementWrapper.js
|
|
179
179
|
* @private
|
180
180
|
* @const
|
181
181
|
*/
|
182
|
-
|
182
|
+
const SUB_ID = "SUB_ID";
|
183
183
|
|
184
184
|
/** @private
|
185
185
|
* @param {RowDefinition} rowDef
|
186
186
|
* @return {Object}
|
187
187
|
*/
|
188
|
-
|
188
|
+
let toRowData = function(rowDef) {
|
189
189
|
return rowDef ? rowDef.getRowData() : null;
|
190
190
|
};
|
191
191
|
|
@@ -193,7 +193,7 @@ var toRowData = function(rowDef) {
|
|
193
193
|
* @const
|
194
194
|
* @type {Object.<string, number>}
|
195
195
|
*/
|
196
|
-
|
196
|
+
let _unclonableFields = {
|
197
197
|
"ROW_DEF": 1,
|
198
198
|
"SUB_ID": 1
|
199
199
|
};
|
@@ -201,10 +201,10 @@ var _unclonableFields = {
|
|
201
201
|
* @param {RowDefinition} fromRowDef
|
202
202
|
* @param {RowDefinition} toRowDef
|
203
203
|
*/
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
for(
|
204
|
+
let cloneRowData = function(fromRowDef, toRowDef) {
|
205
|
+
let from = toRowData(fromRowDef);
|
206
|
+
let to = toRowData(toRowDef);
|
207
|
+
for(let key in from) {
|
208
208
|
if(!_unclonableFields[key]) {
|
209
209
|
to[key] = from[key];
|
210
210
|
}
|
@@ -215,7 +215,7 @@ var cloneRowData = function(fromRowDef, toRowDef) {
|
|
215
215
|
* @param {RowDefinition} rowDef
|
216
216
|
* @return {boolean}
|
217
217
|
*/
|
218
|
-
|
218
|
+
let excludeAutoGenerated = function (rowDef) {
|
219
219
|
return !rowDef.isAutoGenerated();
|
220
220
|
};
|
221
221
|
|
@@ -223,7 +223,7 @@ var excludeAutoGenerated = function (rowDef) {
|
|
223
223
|
* @param {Object} colConfig column config
|
224
224
|
* @return {boolean}
|
225
225
|
*/
|
226
|
-
|
226
|
+
let _byNonAutoGeneratedColumn = function (colConfig) {
|
227
227
|
return !colConfig.autoGenerated;
|
228
228
|
};
|
229
229
|
/** @private
|
@@ -233,7 +233,7 @@ var _byNonAutoGeneratedColumn = function (colConfig) {
|
|
233
233
|
* @param {string} fieldName
|
234
234
|
* @return {number} The outcome of the value comparison
|
235
235
|
*/
|
236
|
-
|
236
|
+
let compareNumber = function(rowDefA, rowDefB, sortOrder, fieldName) { // edit name
|
237
237
|
return (rowDefA.getData(fieldName) - rowDefB.getData(fieldName)) * sortOrder; // for numeric comparison
|
238
238
|
};
|
239
239
|
|
@@ -244,14 +244,14 @@ var compareNumber = function(rowDefA, rowDefB, sortOrder, fieldName) { // edit n
|
|
244
244
|
* @param {string} sortOrder
|
245
245
|
* @return {number} The outcome of the value comparison
|
246
246
|
*/
|
247
|
-
|
248
|
-
|
247
|
+
let _sortChildrenOfChain = function (rowDefA, rowDefB, sortOrder) {
|
248
|
+
let parentA = rowDefA.getParent();
|
249
249
|
|
250
250
|
if (!parentA) {
|
251
251
|
return 0;
|
252
252
|
}
|
253
253
|
|
254
|
-
|
254
|
+
let parentB = rowDefB.getParent();
|
255
255
|
|
256
256
|
if (!parentB) {
|
257
257
|
return 0;
|
@@ -261,13 +261,13 @@ var _sortChildrenOfChain = function (rowDefA, rowDefB, sortOrder) {
|
|
261
261
|
return 0;
|
262
262
|
}
|
263
263
|
|
264
|
-
|
264
|
+
let a = rowDefA.getData('CHILD_ORDER');
|
265
265
|
|
266
266
|
if (a == null) {
|
267
267
|
return 0;
|
268
268
|
}
|
269
269
|
|
270
|
-
|
270
|
+
let b = rowDefB.getData('CHILD_ORDER');
|
271
271
|
|
272
272
|
if (b == null) {
|
273
273
|
return 0;
|
@@ -280,7 +280,7 @@ var _sortChildrenOfChain = function (rowDefA, rowDefB, sortOrder) {
|
|
280
280
|
* @param {ColumnDefinition} colDef
|
281
281
|
* @return {string}
|
282
282
|
*/
|
283
|
-
|
283
|
+
let _getName = function(colDef) {
|
284
284
|
if(colDef) {
|
285
285
|
return colDef.getName();
|
286
286
|
}
|
@@ -291,7 +291,7 @@ var _getName = function(colDef) {
|
|
291
291
|
* @param {string} str
|
292
292
|
* @return {boolean}
|
293
293
|
*/
|
294
|
-
|
294
|
+
let _hasFieldOrId = function(colDef, str) {
|
295
295
|
return (colDef.getField() === str) || (colDef.getId() === str);
|
296
296
|
};
|
297
297
|
|
@@ -301,7 +301,7 @@ var _hasFieldOrId = function(colDef, str) {
|
|
301
301
|
* @param {Object} obj2
|
302
302
|
* @returns {boolean} If the id property of two objects is equal, the return will be true, otherwise it will be false.
|
303
303
|
*/
|
304
|
-
|
304
|
+
let _hasMatchingId = function(obj1, obj2) {
|
305
305
|
if(!obj1 || !obj2 || !obj1.id || !obj2.id) { // Handle nullable, if the object or id have null, it's means difference value
|
306
306
|
return false;
|
307
307
|
}
|
@@ -313,8 +313,8 @@ var _hasMatchingId = function(obj1, obj2) {
|
|
313
313
|
* @param {(Element|null)=} placeholder
|
314
314
|
* @param {Grid~GridOptions=} config
|
315
315
|
*/
|
316
|
-
|
317
|
-
|
316
|
+
let Grid = function(placeholder, config) {
|
317
|
+
let t = this; // This is to primarily reduce file size
|
318
318
|
|
319
319
|
t._onDataChanged = t._onDataChanged.bind(t);
|
320
320
|
t._onQuote2PostUpdate = t._onQuote2PostUpdate.bind(t);
|
@@ -372,7 +372,7 @@ var Grid = function(placeholder, config) {
|
|
372
372
|
t._dt = t._dv.getDataTable();
|
373
373
|
t._mainGrid = config["grid"];
|
374
374
|
|
375
|
-
|
375
|
+
let core = t._mainGrid.getCoreGrid();
|
376
376
|
t._stp = core.getPlugin("SortableTitlePlugin");
|
377
377
|
}
|
378
378
|
if(config["SortableTitle"]) { // Exception for built-in plugin
|
@@ -439,7 +439,6 @@ var Grid = function(placeholder, config) {
|
|
439
439
|
t._connector.addEventListener("fieldRemoved", t._onFieldRemoved.bind(t));
|
440
440
|
|
441
441
|
t.initialize(config);
|
442
|
-
t.initSubscription();
|
443
442
|
|
444
443
|
StyleLoader.applyStyle(t._grid);
|
445
444
|
};
|
@@ -667,7 +666,7 @@ Grid.prototype.initSubscription = function() {
|
|
667
666
|
return;
|
668
667
|
}
|
669
668
|
|
670
|
-
|
669
|
+
let jet, q, s;
|
671
670
|
jet = window["JET"]; // Assume that JET is already exist.
|
672
671
|
if (this._RTK) {
|
673
672
|
q = this._RTK.Quotes;
|
@@ -691,10 +690,10 @@ Grid.prototype.initSubscription = function() {
|
|
691
690
|
|
692
691
|
// TODO: Subscriptions should be registered per row.
|
693
692
|
// However, chain subscription cannot be integrated with DataConnector in this current implementation.
|
694
|
-
|
695
|
-
|
696
|
-
for(
|
697
|
-
|
693
|
+
let rowDefs = this._getAllRowDefinitions();
|
694
|
+
let len = rowDefs.length;
|
695
|
+
for(let i = 0; i < len; ++i) {
|
696
|
+
let rowDef = rowDefs[i];
|
698
697
|
if(rowDef) {
|
699
698
|
rowDef.subscribeForUpdates();
|
700
699
|
}
|
@@ -713,7 +712,7 @@ Grid.prototype.updateLayout = function() {
|
|
713
712
|
*/
|
714
713
|
Grid.prototype._updateRowData = function(rowIndex) {
|
715
714
|
if(rowIndex >= 0) {
|
716
|
-
|
715
|
+
let rowId = this._dv.getRowId(rowIndex);
|
717
716
|
if(rowId) {
|
718
717
|
this._dt.setRowData(rowId, {});
|
719
718
|
}
|
@@ -730,7 +729,7 @@ Grid.prototype.updateRowData = Grid.prototype._updateRowData;
|
|
730
729
|
/** @private
|
731
730
|
*/
|
732
731
|
Grid.prototype._addGridSections = function () {
|
733
|
-
|
732
|
+
let title = this._grid.addSection("title");
|
734
733
|
if(this._topSection == false){
|
735
734
|
title.setRowCount(0);
|
736
735
|
} else {
|
@@ -738,10 +737,10 @@ Grid.prototype._addGridSections = function () {
|
|
738
737
|
}
|
739
738
|
this._grid.addSection("content");
|
740
739
|
|
741
|
-
|
740
|
+
let titleSettings = this._grid.getSectionSettings("title");
|
742
741
|
titleSettings.disableDataBinding();
|
743
742
|
|
744
|
-
|
743
|
+
let contentSettings = this._grid.getSectionSettings("content");
|
745
744
|
contentSettings.setAutoSyncRowCount(true);
|
746
745
|
contentSettings.setParent(titleSettings);
|
747
746
|
};
|
@@ -750,13 +749,13 @@ Grid.prototype._addGridSections = function () {
|
|
750
749
|
* @return {*} Return Section instance
|
751
750
|
*/
|
752
751
|
Grid.prototype.addHeaderSection = function (sectionName) {
|
753
|
-
|
752
|
+
let titleSects = this._grid.getAllSections("title");
|
754
753
|
|
755
|
-
|
754
|
+
let headerSect = this._grid.addSectionAt(titleSects.length, "title", sectionName);
|
756
755
|
if(headerSect) {
|
757
756
|
headerSect.setRowCount(1);
|
758
757
|
|
759
|
-
|
758
|
+
let headerSettings = this._grid.getSectionSettings(headerSect);
|
760
759
|
headerSettings.disableDataBinding();
|
761
760
|
}
|
762
761
|
|
@@ -767,11 +766,11 @@ Grid.prototype.addHeaderSection = function (sectionName) {
|
|
767
766
|
* @return {*} Return Section instance
|
768
767
|
*/
|
769
768
|
Grid.prototype.addFooterSection = function (sectionName) {
|
770
|
-
|
769
|
+
let footerSect = this._grid.addSection("footer", sectionName);
|
771
770
|
if(footerSect) {
|
772
771
|
footerSect.setRowCount(1);
|
773
772
|
|
774
|
-
|
773
|
+
let footerSettings = this._grid.getSectionSettings(footerSect);
|
775
774
|
footerSettings.disableDataBinding();
|
776
775
|
}
|
777
776
|
|
@@ -790,7 +789,7 @@ Grid.prototype.setParent = function (elem) {
|
|
790
789
|
*/
|
791
790
|
Grid.prototype.insertBefore = function (elem) {
|
792
791
|
if(elem) {
|
793
|
-
|
792
|
+
let pn = elem.parentNode;
|
794
793
|
if(pn) {
|
795
794
|
pn.insertBefore(this._topNode, elem);
|
796
795
|
this.updateLayout();
|
@@ -824,17 +823,20 @@ Grid.prototype.getCoreGrid = function () {
|
|
824
823
|
* @param {Grid~GridOptions=} gridOption
|
825
824
|
*/
|
826
825
|
Grid.prototype.initialize = function(gridOption) {
|
827
|
-
if (!gridOption) {
|
826
|
+
if (!gridOption) {
|
827
|
+
this.initSubscription();
|
828
|
+
return;
|
829
|
+
}
|
828
830
|
// TODO: clear all data before re-initialization
|
829
|
-
|
831
|
+
let t = this; // For minimizing file size
|
830
832
|
t._initializing = true;
|
831
|
-
|
833
|
+
let grid = t._grid; // core grid
|
832
834
|
grid.resetInternalState();
|
833
835
|
gridOption = grid.normalizeConfig(gridOption);
|
834
836
|
|
835
|
-
|
837
|
+
let exts = gridOption["plugins"] || gridOption["extensions"];
|
836
838
|
|
837
|
-
|
839
|
+
let cols = /** @type{Array} */(gridOption["fields"] || gridOption["columns"]);
|
838
840
|
if (gridOption["defaultColumnOptions"]) {
|
839
841
|
t._defaultColumnOptions = gridOption["defaultColumnOptions"];
|
840
842
|
t._defaultColumnSetup(t._defaultColumnOptions, cols);
|
@@ -884,23 +886,23 @@ Grid.prototype.initialize = function(gridOption) {
|
|
884
886
|
t._fnEngine.addEventListener("dataRequired", t._onFormulaDataRequired);
|
885
887
|
}
|
886
888
|
|
887
|
-
|
889
|
+
let borders = gridOption["borders"];
|
888
890
|
if (borders != null) {
|
889
891
|
grid.toggleBorders(borders);
|
890
892
|
}
|
891
|
-
|
893
|
+
let gridlines = gridOption["gridlines"];
|
892
894
|
if (gridlines != null) {
|
893
895
|
grid.toggleGridlines(gridlines);
|
894
896
|
}
|
895
|
-
|
897
|
+
let vLines = gridOption["verticalLines"];
|
896
898
|
if (vLines != null) {
|
897
899
|
grid.toggleVerticalLines(vLines);
|
898
900
|
}
|
899
|
-
|
901
|
+
let cvLines = gridOption["contentVerticalLines"];
|
900
902
|
if (cvLines != null) {
|
901
903
|
grid.toggleContentVerticalLines(cvLines);
|
902
904
|
}
|
903
|
-
|
905
|
+
let hLines = gridOption["horizontalLines"];
|
904
906
|
if (hLines != null) {
|
905
907
|
grid.toggleHorizontalLines(hLines);
|
906
908
|
}
|
@@ -909,28 +911,28 @@ Grid.prototype.initialize = function(gridOption) {
|
|
909
911
|
t._dv.setPageSize(+gridOption["pageSize"]);
|
910
912
|
}
|
911
913
|
|
912
|
-
|
914
|
+
let rowHeight = +gridOption["rowHeight"];
|
913
915
|
if(rowHeight) { // Non empty or zero
|
914
916
|
grid.setDefaultRowHeight(rowHeight);
|
915
917
|
}
|
916
|
-
|
918
|
+
let hRowHeight = +gridOption["headerRowHeight"];
|
917
919
|
if(hRowHeight) { // Non empty or zero
|
918
920
|
grid.getSection("title").setDefaultRowHeight(hRowHeight);
|
919
921
|
}
|
920
922
|
|
921
|
-
|
923
|
+
let val = gridOption["autoLayoutUpdate"];
|
922
924
|
if(!t._autoLayoutTimer && val) {
|
923
925
|
if(val !== "0" && val !== "false") { // HACK: Temporarily support incorrect data type
|
924
926
|
t._autoLayoutTimer = setInterval(t._onAutoLayoutUpdate.bind(t), 2000);
|
925
927
|
}
|
926
928
|
}
|
927
929
|
|
928
|
-
|
930
|
+
let bool = gridOption["rowHighlighting"];
|
929
931
|
if(bool != null) {
|
930
932
|
grid.enableRowHighlighting(!!bool);
|
931
933
|
}
|
932
934
|
|
933
|
-
|
935
|
+
let rowExpansionBinding = gridOption["rowExpansionBinding"];
|
934
936
|
if(typeof rowExpansionBinding === "function") {
|
935
937
|
grid.listen("rowExpansionBinding", t._onRowExpansionBinding); // TODO: Support multi-table feature
|
936
938
|
t.listen("rowExpansionBinding", rowExpansionBinding);
|
@@ -957,7 +959,7 @@ Grid.prototype.initialize = function(gridOption) {
|
|
957
959
|
if(gridOption["scrollbarParent"] != null) {
|
958
960
|
t._setScrollbarParent(gridOption["scrollbarParent"]);
|
959
961
|
}
|
960
|
-
|
962
|
+
let pollingInterval = gridOption["adcPollingInterval"];
|
961
963
|
if(pollingInterval != null) {
|
962
964
|
t._pollingInterval = pollingInterval ? +pollingInterval : 0;
|
963
965
|
}
|
@@ -965,7 +967,7 @@ Grid.prototype.initialize = function(gridOption) {
|
|
965
967
|
// Column operations
|
966
968
|
t.setColumns(cols);
|
967
969
|
|
968
|
-
|
970
|
+
let rowVir = true;
|
969
971
|
if (gridOption["rowVirtualRendering"] != null) {
|
970
972
|
rowVir = gridOption["rowVirtualRendering"];
|
971
973
|
}
|
@@ -974,7 +976,7 @@ Grid.prototype.initialize = function(gridOption) {
|
|
974
976
|
}
|
975
977
|
grid.enableRowVirtualization(!!rowVir);
|
976
978
|
|
977
|
-
|
979
|
+
let colVir = false;
|
978
980
|
if (gridOption["columnVirtualRendering"] != null) {
|
979
981
|
colVir = gridOption["columnVirtualRendering"];
|
980
982
|
}
|
@@ -983,7 +985,7 @@ Grid.prototype.initialize = function(gridOption) {
|
|
983
985
|
}
|
984
986
|
grid.enableColumnVirtualization(!!colVir);
|
985
987
|
|
986
|
-
|
988
|
+
let scrollbar = gridOption["scrollbar"] != null ? gridOption["scrollbar"] : true;
|
987
989
|
if (scrollbar) {
|
988
990
|
t._topNode.style.overflow = "hidden"; // TODO: Move this to CSS Class
|
989
991
|
} else {
|
@@ -991,16 +993,16 @@ Grid.prototype.initialize = function(gridOption) {
|
|
991
993
|
t._topNode.style.overflow = "";
|
992
994
|
}
|
993
995
|
|
994
|
-
|
996
|
+
let topFreezingCount = gridOption["topFreezingCount"];
|
995
997
|
if (typeof topFreezingCount === "number") {
|
996
998
|
topFreezingCount = (topFreezingCount > 0) ? topFreezingCount : 0;
|
997
|
-
|
999
|
+
let sectionIndex = topFreezingCount - 1;
|
998
1000
|
grid.freezeSection(sectionIndex);
|
999
1001
|
} else if (topFreezingCount === false) {
|
1000
1002
|
grid.freezeSection(null);
|
1001
1003
|
}
|
1002
1004
|
|
1003
|
-
|
1005
|
+
let bottomFreezingCount = gridOption["bottomFreezingCount"];
|
1004
1006
|
if (typeof bottomFreezingCount === "number") {
|
1005
1007
|
bottomFreezingCount = (bottomFreezingCount > 0) ? bottomFreezingCount : 0;
|
1006
1008
|
grid.freezeFooter(bottomFreezingCount);
|
@@ -1011,11 +1013,11 @@ Grid.prototype.initialize = function(gridOption) {
|
|
1011
1013
|
// Plugins
|
1012
1014
|
gridOption[ROW_DEF] = true; // Enable ROW_DEF mode
|
1013
1015
|
if (Array.isArray(exts)) {
|
1014
|
-
for (
|
1015
|
-
|
1016
|
-
|
1016
|
+
for (let i = 0; i < exts.length; ++i) {
|
1017
|
+
let ext = exts[i];
|
1018
|
+
let extInstance = null;
|
1017
1019
|
if (ext) {
|
1018
|
-
|
1020
|
+
let extName = ext["name"];
|
1019
1021
|
if(extName) {
|
1020
1022
|
extInstance = grid.loadPlugin(extName, ext); // pass plugin object as an argument for initialization
|
1021
1023
|
} else {
|
@@ -1023,7 +1025,7 @@ Grid.prototype.initialize = function(gridOption) {
|
|
1023
1025
|
}
|
1024
1026
|
}
|
1025
1027
|
if (extInstance && extInstance["setGridWrapper"]) {
|
1026
|
-
|
1028
|
+
let hasApi = (typeof extInstance["getGridApi"] === "function") ? extInstance["getGridApi"]() : false;
|
1027
1029
|
if(!hasApi) {
|
1028
1030
|
extInstance["setGridWrapper"]("realTimeGrid", t);
|
1029
1031
|
}
|
@@ -1032,7 +1034,7 @@ Grid.prototype.initialize = function(gridOption) {
|
|
1032
1034
|
t._initializing = false;
|
1033
1035
|
}
|
1034
1036
|
|
1035
|
-
|
1037
|
+
let lang = gridOption["lang"];
|
1036
1038
|
if(lang != null) {
|
1037
1039
|
t._lang = lang;
|
1038
1040
|
t._dateTimeUtil.setLocale(lang);
|
@@ -1042,18 +1044,18 @@ Grid.prototype.initialize = function(gridOption) {
|
|
1042
1044
|
if(gridOption["childDataField"] != null) {
|
1043
1045
|
this._childDataField = RowDefinition._childDataField = gridOption["childDataField"];
|
1044
1046
|
}
|
1045
|
-
|
1047
|
+
let rows = gridOption["rows"];
|
1046
1048
|
if(!rows) {
|
1047
1049
|
rows = gridOption["rics"] || null; // Make "rics" an alias to "rows"
|
1048
1050
|
}
|
1049
|
-
|
1051
|
+
let bodies = /** @type{Array} */(gridOption["bodies"]);
|
1050
1052
|
if(!bodies) {
|
1051
1053
|
bodies = [];
|
1052
1054
|
if(gridOption["body"]) {
|
1053
1055
|
bodies.push(gridOption["body"]);
|
1054
1056
|
}
|
1055
1057
|
if(rows) {
|
1056
|
-
for(
|
1058
|
+
for(let m = 0; m < rows.length; m++) {
|
1057
1059
|
if(typeof rows[m] === "string") {
|
1058
1060
|
rows[m] = { "ric": rows[m] };
|
1059
1061
|
}
|
@@ -1063,13 +1065,13 @@ Grid.prototype.initialize = function(gridOption) {
|
|
1063
1065
|
}
|
1064
1066
|
|
1065
1067
|
// Merge rows with static data rows
|
1066
|
-
|
1068
|
+
let staticRows = gridOption["staticDataRows"] || gridOption["dataModel"];
|
1067
1069
|
if(rows && staticRows) {
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
for(
|
1070
|
+
let ary = staticRows["data"] ? staticRows["data"] : staticRows;
|
1071
|
+
let fields = staticRows["fields"] || t.getColumnFields();
|
1072
|
+
let values, data;
|
1073
|
+
let len = rows.length;
|
1074
|
+
for(let n = 0; n < len; n++) {
|
1073
1075
|
if(rows[n]["values"]) { // merge row's values, values can be object or array
|
1074
1076
|
values = arrayToObject(rows[n]["values"], fields);
|
1075
1077
|
data = arrayToObject(ary[n], fields);
|
@@ -1086,7 +1088,7 @@ Grid.prototype.initialize = function(gridOption) {
|
|
1086
1088
|
}
|
1087
1089
|
}
|
1088
1090
|
|
1089
|
-
for(
|
1091
|
+
for(let j = 0; j < bodies.length; ++j) {
|
1090
1092
|
t.insertRows(bodies[j]["rows"]);
|
1091
1093
|
// break; // TODO: The first version supports only 1 grid
|
1092
1094
|
}
|
@@ -1097,7 +1099,7 @@ Grid.prototype.initialize = function(gridOption) {
|
|
1097
1099
|
grid.setBottomPaddingSection(gridOption.contentBottomPadding);
|
1098
1100
|
}
|
1099
1101
|
|
1100
|
-
|
1102
|
+
let contentRightPadding = gridOption.contentRightPadding;
|
1101
1103
|
if(contentRightPadding) {
|
1102
1104
|
if (typeof contentRightPadding !== "number") {
|
1103
1105
|
contentRightPadding = 6;
|
@@ -1108,14 +1110,15 @@ Grid.prototype.initialize = function(gridOption) {
|
|
1108
1110
|
|
1109
1111
|
// Let everything init first
|
1110
1112
|
// then set conflationRate to grid for better perfomance on rapidly updating
|
1111
|
-
|
1113
|
+
let dataConflationRate = gridOption['dataConflationRate'];
|
1112
1114
|
if (dataConflationRate != null) {
|
1113
1115
|
grid.setDataConflationRate(dataConflationRate);
|
1114
1116
|
}
|
1115
1117
|
|
1116
1118
|
// Tell all plugins that the initialization phase has ended
|
1117
|
-
|
1119
|
+
let extObjects = grid.getPluginList().map(grid.getPlugin.bind(grid));
|
1118
1120
|
t._processExtension(extObjects, "afterInit");
|
1121
|
+
t.initSubscription();
|
1119
1122
|
};
|
1120
1123
|
|
1121
1124
|
/** @public
|
@@ -1123,14 +1126,14 @@ Grid.prototype.initialize = function(gridOption) {
|
|
1123
1126
|
* @return {!Object}
|
1124
1127
|
*/
|
1125
1128
|
Grid.prototype.getConfigObject = function (gridOptions) {
|
1126
|
-
|
1129
|
+
let obj = gridOptions || {};
|
1127
1130
|
|
1128
|
-
|
1131
|
+
let columns = obj.columns;
|
1129
1132
|
if(!columns) {
|
1130
1133
|
columns = obj.columns = [];
|
1131
1134
|
}
|
1132
1135
|
|
1133
|
-
|
1136
|
+
let grid = this._grid;
|
1134
1137
|
if(grid.getConfigObject) {
|
1135
1138
|
grid.getConfigObject(obj);
|
1136
1139
|
}
|
@@ -1157,17 +1160,17 @@ Grid.prototype.getConfigObject = function (gridOptions) {
|
|
1157
1160
|
}
|
1158
1161
|
|
1159
1162
|
|
1160
|
-
|
1163
|
+
let i, len, prevTimeSeriesField;
|
1161
1164
|
len = this.getColumnCount();
|
1162
1165
|
for (i = 0; i < len; ++i) {
|
1163
|
-
|
1166
|
+
let column = columns[i];
|
1164
1167
|
if(!column) {
|
1165
1168
|
column = columns[i] = {};
|
1166
1169
|
}
|
1167
|
-
|
1170
|
+
let colDef = this.getColumnDefinition(i);
|
1168
1171
|
// TODO: Update width and scalability changed by the extensions
|
1169
1172
|
colDef.getConfigObject(column);
|
1170
|
-
|
1173
|
+
let parentField = FieldDefinition.getFieldProperty(colDef.getField(), "timeSeriesParent");
|
1171
1174
|
if(parentField && !prevTimeSeriesField) { // Assume first column of time series child to convert to time series parent
|
1172
1175
|
prevTimeSeriesField = parentField;
|
1173
1176
|
column.field = parentField;
|
@@ -1185,7 +1188,7 @@ Grid.prototype.getConfigObject = function (gridOptions) {
|
|
1185
1188
|
obj["scrollbar"] = false;
|
1186
1189
|
}
|
1187
1190
|
|
1188
|
-
|
1191
|
+
let val = this._dv.getPageSize();
|
1189
1192
|
if(val > 0) {
|
1190
1193
|
obj["pageSize"] = val;
|
1191
1194
|
}
|
@@ -1238,9 +1241,9 @@ Grid.prototype.getConfigObject = function (gridOptions) {
|
|
1238
1241
|
}
|
1239
1242
|
|
1240
1243
|
// get all rows config
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
+
let rowDefs = this.getAllRowDefinitions();
|
1245
|
+
let rows = obj["rows"] = [];
|
1246
|
+
let rowDef, rowConfig;
|
1244
1247
|
len = rowDefs.length;
|
1245
1248
|
for (i = 0; i < len; i++) {
|
1246
1249
|
rowDef = rowDefs[i];
|
@@ -1249,9 +1252,9 @@ Grid.prototype.getConfigObject = function (gridOptions) {
|
|
1249
1252
|
}
|
1250
1253
|
|
1251
1254
|
// get row config from extensions
|
1252
|
-
|
1253
|
-
|
1254
|
-
for(
|
1255
|
+
let extensions = grid.getPlugins();
|
1256
|
+
let pluginInstance, row;
|
1257
|
+
for(let key in extensions) {
|
1255
1258
|
pluginInstance = extensions[key];
|
1256
1259
|
if(typeof pluginInstance["getRowConfigObject"] === "function") {
|
1257
1260
|
len = rows.length;
|
@@ -1303,11 +1306,11 @@ Grid.prototype.setLocale = function(lang) {
|
|
1303
1306
|
* @param {Array.<Object>} userColumns
|
1304
1307
|
*/
|
1305
1308
|
Grid.prototype._defaultColumnSetup = function (defaultCol, userColumns) {
|
1306
|
-
|
1307
|
-
for (
|
1308
|
-
|
1309
|
+
let c = userColumns.length;
|
1310
|
+
for (let i = 0; i < c; i++) {
|
1311
|
+
let column = userColumns[i];
|
1309
1312
|
if (typeof column === 'object') {
|
1310
|
-
for (
|
1313
|
+
for (let key in defaultCol) {
|
1311
1314
|
if (column[key] == null) {
|
1312
1315
|
column[key] = defaultCol[key];
|
1313
1316
|
}
|
@@ -1325,7 +1328,7 @@ Grid.prototype._defaultColumnSetup = function (defaultCol, userColumns) {
|
|
1325
1328
|
*/
|
1326
1329
|
Grid.prototype._processExtension = function (exts, field, params) {
|
1327
1330
|
if(Array.isArray(exts)) {
|
1328
|
-
for (
|
1331
|
+
for (let i = 0; i < exts.length; i++) {
|
1329
1332
|
if (exts[i][field]) {
|
1330
1333
|
exts[i][field].apply(exts[i], params);
|
1331
1334
|
}
|
@@ -1337,15 +1340,15 @@ Grid.prototype._processExtension = function (exts, field, params) {
|
|
1337
1340
|
* @param {Object} e
|
1338
1341
|
*/
|
1339
1342
|
Grid.prototype._onRicAdded = function(e) {
|
1340
|
-
|
1343
|
+
let addedRics = e.addedRics;
|
1341
1344
|
this._snapshot.addFields(e.fields);
|
1342
|
-
|
1343
|
-
for (
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
for (
|
1348
|
-
|
1345
|
+
let len = addedRics.length;
|
1346
|
+
for (let i = 0; i < len; ++i) {
|
1347
|
+
let ric = addedRics[i];
|
1348
|
+
let rowDefs = this._connector.getRowDefByRic(ric);
|
1349
|
+
let jLen = rowDefs ? rowDefs.length : 0;
|
1350
|
+
for (let j = 0; j < jLen; ++j) {
|
1351
|
+
let rowDef = rowDefs[j];
|
1349
1352
|
if (rowDef.getSymbol() === ric) {
|
1350
1353
|
this._snapshot.addRic(ric); // ADC
|
1351
1354
|
}
|
@@ -1366,18 +1369,18 @@ Grid.prototype._onRicRemoved = function(e) {
|
|
1366
1369
|
* @param {Object} e
|
1367
1370
|
*/
|
1368
1371
|
Grid.prototype._onFieldAdded = function(e) {
|
1369
|
-
|
1370
|
-
|
1372
|
+
let rowDefs = e.rowDefs;
|
1373
|
+
let addedFields = e.addedFields;
|
1371
1374
|
|
1372
1375
|
// ADC
|
1373
|
-
for (
|
1376
|
+
for (let i in rowDefs) {
|
1374
1377
|
this._snapshot.addRic(rowDefs[i].getSymbol());
|
1375
1378
|
}
|
1376
1379
|
this._snapshot.addFields(addedFields);
|
1377
1380
|
|
1378
1381
|
// JET
|
1379
1382
|
if (this._subs) {
|
1380
|
-
|
1383
|
+
let realtimeFields = addedFields.filter(FieldDefinition.isRealTimeField);
|
1381
1384
|
if(realtimeFields.length > 0) {
|
1382
1385
|
this._subs["addFields"](realtimeFields);
|
1383
1386
|
}
|
@@ -1389,7 +1392,7 @@ Grid.prototype._onFieldAdded = function(e) {
|
|
1389
1392
|
* @param {Object} e
|
1390
1393
|
*/
|
1391
1394
|
Grid.prototype._onFieldRemoved = function(e) {
|
1392
|
-
|
1395
|
+
let removedFields = e.removedFields;
|
1393
1396
|
|
1394
1397
|
// TODO: ADC fields have an interval load. Currently, we only keep the field but do not delete it.
|
1395
1398
|
// JET
|
@@ -1405,19 +1408,19 @@ Grid.prototype._onFieldRemoved = function(e) {
|
|
1405
1408
|
* @param {number=} idx
|
1406
1409
|
*/
|
1407
1410
|
Grid.prototype.insertColumn = function (columnOption, idx) {
|
1408
|
-
|
1411
|
+
let colCount = this.getColumnCount();
|
1409
1412
|
if(idx == null || idx > colCount) {
|
1410
1413
|
idx = colCount;
|
1411
1414
|
}
|
1412
1415
|
|
1413
1416
|
// no need to merge defaultColumn during initialize process
|
1414
1417
|
// because columnOption already mutate by initialize function
|
1415
|
-
|
1418
|
+
let configObj = (this._initializing) ? {} : cloneObject(this._defaultColumnOptions);
|
1416
1419
|
|
1417
1420
|
if (typeof columnOption === "string") {
|
1418
1421
|
configObj["field"] = columnOption;
|
1419
1422
|
} else { // columnOption is assumed to be an object
|
1420
|
-
for (
|
1423
|
+
for (let key in columnOption) {
|
1421
1424
|
configObj[key] = columnOption[key];
|
1422
1425
|
}
|
1423
1426
|
}
|
@@ -1426,7 +1429,7 @@ Grid.prototype.insertColumn = function (columnOption, idx) {
|
|
1426
1429
|
configObj["formulaEngine"] = this._fnEngine; // Adding extra option
|
1427
1430
|
}
|
1428
1431
|
|
1429
|
-
|
1432
|
+
let colDef = new ColumnDefinition(configObj, this);
|
1430
1433
|
configObj[COL_DEF] = colDef;
|
1431
1434
|
|
1432
1435
|
// WARNING: width is processed twice by tr-grid and rt-grid
|
@@ -1439,18 +1442,18 @@ Grid.prototype.insertColumn = function (columnOption, idx) {
|
|
1439
1442
|
* @param {Object} e snapshort change event object
|
1440
1443
|
*/
|
1441
1444
|
Grid.prototype._updateTimeSeriesFields = function (e) {
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
for (
|
1445
|
+
let childField;
|
1446
|
+
let snapShotData = e.data;
|
1447
|
+
let childFields = {};
|
1448
|
+
for (let ric in snapShotData) {
|
1446
1449
|
// childFields = snapShotData[ric];
|
1447
1450
|
for (childField in snapShotData[ric]) {
|
1448
1451
|
childFields[childField] = true; // Merge child fields to parent (Don't truth each ric it will be have some empty data)
|
1449
1452
|
}
|
1450
1453
|
this.setRicData(ric, snapShotData[ric]); // update cell data if exist
|
1451
1454
|
}
|
1452
|
-
|
1453
|
-
|
1455
|
+
let parentField, field, colIndex, parentColDef, childColIndex;
|
1456
|
+
let parentMap = {}; // map parent time series field and their first child
|
1454
1457
|
for (field in childFields) { // Warning: data change can be differ time series child field
|
1455
1458
|
parentField = e.childrenFieldToParent[field];
|
1456
1459
|
if(!parentMap[parentField]) {
|
@@ -1461,10 +1464,10 @@ Grid.prototype._updateTimeSeriesFields = function (e) {
|
|
1461
1464
|
}
|
1462
1465
|
|
1463
1466
|
for (parentField in parentMap) { // WARNING: one dataChanged event can be multiple fields
|
1464
|
-
|
1467
|
+
let childrenField = parentMap[parentField];
|
1465
1468
|
colIndex = this.getColumnIndex(parentField);
|
1466
1469
|
parentColDef = this._getColumnDefinition(colIndex);
|
1467
|
-
|
1470
|
+
let i, len;
|
1468
1471
|
len = childrenField.length;
|
1469
1472
|
for (i = 0; i < len; i++) {
|
1470
1473
|
childField = childrenField[i];
|
@@ -1490,8 +1493,8 @@ Grid.prototype._populateTimeSeriesChildren = function (colDef) {
|
|
1490
1493
|
return;
|
1491
1494
|
}
|
1492
1495
|
|
1493
|
-
|
1494
|
-
|
1496
|
+
let colDefs = this._timeSeriesChildConflator.popAllData();
|
1497
|
+
let i, j, len, childField, idx;
|
1495
1498
|
|
1496
1499
|
for (i = 0; i < colDefs.length; i++) {
|
1497
1500
|
colDef = colDefs[i];
|
@@ -1500,8 +1503,8 @@ Grid.prototype._populateTimeSeriesChildren = function (colDef) {
|
|
1500
1503
|
if(!colDef) {
|
1501
1504
|
continue;
|
1502
1505
|
}
|
1503
|
-
|
1504
|
-
|
1506
|
+
let parentField = colDef.getField();
|
1507
|
+
let childFields = FieldDefinition.getTimeSeriesChildren(parentField);
|
1505
1508
|
if(!childFields) { // not found time series field
|
1506
1509
|
return;
|
1507
1510
|
}
|
@@ -1526,7 +1529,7 @@ Grid.prototype._populateTimeSeriesChildren = function (colDef) {
|
|
1526
1529
|
* @param {number} idx index of insertion column
|
1527
1530
|
*/
|
1528
1531
|
Grid.prototype._cloneTimeSeriesColumn = function (parentColDef, childField, idx) {
|
1529
|
-
|
1532
|
+
let parentConfig, columnOption;
|
1530
1533
|
parentConfig = parentColDef.getConfigObject();
|
1531
1534
|
columnOption = cloneObject(parentConfig);
|
1532
1535
|
columnOption["field"] = childField.replace("TR.", ""); // We need to remove the 'TR' prefix from the field to avoid confusion with time series fields.
|
@@ -1543,15 +1546,15 @@ Grid.prototype._cloneTimeSeriesColumn = function (parentColDef, childField, idx)
|
|
1543
1546
|
* @param {Grid~ColumnReference} colRef
|
1544
1547
|
*/
|
1545
1548
|
Grid.prototype.replaceColumn = function (columnOption, colRef) {
|
1546
|
-
|
1549
|
+
let colIndex = this.getColumnIndex(colRef);
|
1547
1550
|
if(colIndex < 0) {
|
1548
1551
|
return;
|
1549
1552
|
}
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
+
let colConfig = {};
|
1554
|
+
let core = this._grid;
|
1555
|
+
let columnDef = core._getColumnDef(colIndex);
|
1553
1556
|
|
1554
|
-
|
1557
|
+
let value = core.getColumnScalability(colIndex);
|
1555
1558
|
colConfig["scalable"] = value;
|
1556
1559
|
|
1557
1560
|
value = core.getColumnCustomLaneSize(colIndex);
|
@@ -1585,7 +1588,7 @@ Grid.prototype.replaceColumn = function (columnOption, colRef) {
|
|
1585
1588
|
if(typeof columnOption === "string") {
|
1586
1589
|
colConfig["field"] = columnOption;
|
1587
1590
|
} else { // type object from user
|
1588
|
-
for (
|
1591
|
+
for (let key in columnOption) {
|
1589
1592
|
colConfig[key] = columnOption[key];
|
1590
1593
|
}
|
1591
1594
|
}
|
@@ -1598,7 +1601,7 @@ Grid.prototype.replaceColumn = function (columnOption, colRef) {
|
|
1598
1601
|
colConfig["width"] = 1;
|
1599
1602
|
}
|
1600
1603
|
|
1601
|
-
|
1604
|
+
let colDef = this.getColumnDefinition(colIndex);
|
1602
1605
|
if(colDef && colConfig.id == null) {
|
1603
1606
|
colConfig.id = colDef.getId(); // retain ID
|
1604
1607
|
}
|
@@ -1616,7 +1619,7 @@ Grid.prototype.replaceColumn = function (columnOption, colRef) {
|
|
1616
1619
|
*/
|
1617
1620
|
Grid.prototype._onFieldLoadedSuccess = function (field, colDef, response) {
|
1618
1621
|
if (response && response.id) {
|
1619
|
-
|
1622
|
+
let fieldDef = response;
|
1620
1623
|
if (colDef && colDef.getField() === field) {
|
1621
1624
|
if (colDef.isDefaultName() && fieldDef.name) {
|
1622
1625
|
colDef.setName(fieldDef.name);
|
@@ -1642,7 +1645,7 @@ Grid.prototype._onFieldLoadedError = function (err) {
|
|
1642
1645
|
Grid.prototype._onFieldLoaded = function (field, referrer) {
|
1643
1646
|
// For time series, we need to wait until the field is loadedm, then we can insert a child from the field data.
|
1644
1647
|
if(FieldDefinition.isTimeSeries(field)) {
|
1645
|
-
|
1648
|
+
let colDef = this.getColumnDefinitionById(referrer); // The 'referrer' is a column ID that was just added
|
1646
1649
|
this._populateTimeSeriesChildren(colDef);
|
1647
1650
|
}
|
1648
1651
|
this._connector.addFields(field, referrer);
|
@@ -1679,14 +1682,14 @@ Grid.prototype.getFieldInfo = function(field) {
|
|
1679
1682
|
* @param {string} field
|
1680
1683
|
* @return {Promise}
|
1681
1684
|
* @example
|
1682
|
-
*
|
1685
|
+
* let gridConfig = {
|
1683
1686
|
* synapse: { // define synapse configuration
|
1684
1687
|
* apiKey: "xxx",
|
1685
1688
|
* contextApp: "xxx",
|
1686
1689
|
* auth: "xxx" (optional)
|
1687
1690
|
* }
|
1688
1691
|
* };
|
1689
|
-
*
|
1692
|
+
* let promise = grid.loadFieldInfo("CF_LAST");
|
1690
1693
|
*/
|
1691
1694
|
Grid.prototype.loadFieldInfo = function(field) {
|
1692
1695
|
return FieldDefinition.loadFieldInfo(field);
|
@@ -1699,7 +1702,7 @@ Grid.prototype.loadFieldInfo = function(field) {
|
|
1699
1702
|
*/
|
1700
1703
|
Grid.prototype._shouldLoadFieldInfo = function (field) {
|
1701
1704
|
|
1702
|
-
|
1705
|
+
let val = this._RTK || window["JET"]; // Fastest checking can be performed by checking the first condition.
|
1703
1706
|
if(!val) {
|
1704
1707
|
return false;
|
1705
1708
|
}
|
@@ -1726,17 +1729,17 @@ Grid.prototype._shouldLoadFieldInfo = function (field) {
|
|
1726
1729
|
* @param {Array.<Object>} columns Array of column options
|
1727
1730
|
*/
|
1728
1731
|
Grid.prototype.setColumns = function(columns) {
|
1729
|
-
|
1730
|
-
|
1732
|
+
let grid = this._grid;
|
1733
|
+
let colCount = (columns) ? columns.length : 0;
|
1731
1734
|
|
1732
1735
|
grid.startBatch("reset");
|
1733
1736
|
this.removeAllColumns();
|
1734
1737
|
if(colCount > 0) {
|
1735
|
-
|
1738
|
+
let prevState = false;
|
1736
1739
|
if(colCount > 1) {
|
1737
1740
|
prevState = grid.freezeLayout(true); // Insert multiple columns can be a huge time consuming
|
1738
1741
|
}
|
1739
|
-
for(
|
1742
|
+
for(let i = 0; i < colCount; ++i) {
|
1740
1743
|
this.insertColumn(columns[i], i);
|
1741
1744
|
}
|
1742
1745
|
if(colCount > 1) {
|
@@ -1753,20 +1756,20 @@ Grid.prototype.setColumns = function(columns) {
|
|
1753
1756
|
* @param {boolean=} byId=false, if enable it, this method will only check for differences in the 'id' property
|
1754
1757
|
*/
|
1755
1758
|
Grid.prototype.restoreColumns = function(columns, byId) {
|
1756
|
-
|
1759
|
+
let grid = this._grid;
|
1757
1760
|
grid.startBatch("reset");
|
1758
|
-
|
1759
|
-
|
1761
|
+
let configObj = this.getConfigObject();
|
1762
|
+
let previousColumns = configObj.columns;
|
1760
1763
|
|
1761
|
-
|
1762
|
-
|
1764
|
+
let preColLen = previousColumns.length;
|
1765
|
+
let newColLen = columns.length;
|
1763
1766
|
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1767
|
+
let compareLogic = byId ? _hasMatchingId : deepEqual;
|
1768
|
+
let removingFields = [];
|
1769
|
+
let keepingColumns = [];
|
1770
|
+
let columnOrdering = [];
|
1768
1771
|
|
1769
|
-
|
1772
|
+
let i, j, found;
|
1770
1773
|
// Slow, time complexity BigO(n ^ 2)
|
1771
1774
|
for (i = 0; i < preColLen; i++) {
|
1772
1775
|
found = false;
|
@@ -1784,8 +1787,8 @@ Grid.prototype.restoreColumns = function(columns, byId) {
|
|
1784
1787
|
|
1785
1788
|
this.removeColumns(removingFields);
|
1786
1789
|
|
1787
|
-
|
1788
|
-
|
1790
|
+
let keepingLen = keepingColumns.length;
|
1791
|
+
let prevState = false;
|
1789
1792
|
if(newColLen > 1) {
|
1790
1793
|
prevState = this._grid.freezeLayout(true); // Insert multiple columns can be a huge time consuming
|
1791
1794
|
}
|
@@ -1794,7 +1797,7 @@ Grid.prototype.restoreColumns = function(columns, byId) {
|
|
1794
1797
|
for (j = 0; j < keepingLen; j++) { // loop only keeping column
|
1795
1798
|
if(compareLogic(columns[i], keepingColumns[j])) {
|
1796
1799
|
found = true;
|
1797
|
-
|
1800
|
+
let colIndex = this.getColumnIndex(columns[i].id || columns[i].field); // We cannot use 'i' (colIndex) in this case, as it will sort the columns. Instead, we need to obtain a new column index from the field.
|
1798
1801
|
columnOrdering.push(this.getColumnId(colIndex));
|
1799
1802
|
break;
|
1800
1803
|
}
|
@@ -1825,27 +1828,27 @@ Grid.prototype.setFields = Grid.prototype.setColumns;
|
|
1825
1828
|
* @param {Object} e
|
1826
1829
|
*/
|
1827
1830
|
Grid.prototype._onColumnAdded = function(e) {
|
1828
|
-
|
1831
|
+
let colDef = /** @type{ColumnDefinition} */(e.context[COL_DEF]);
|
1829
1832
|
delete e.context[COL_DEF];
|
1830
|
-
|
1833
|
+
let idx = e.colIndex;
|
1831
1834
|
|
1832
|
-
|
1835
|
+
let coreColDef = this._grid._getColumnDef(idx);
|
1833
1836
|
colDef._setCoreColumnDef(coreColDef); // For column id and field
|
1834
1837
|
|
1835
|
-
|
1838
|
+
let colData = this._grid.getColumnData(idx);
|
1836
1839
|
if(!colData) { // Save column inside grid
|
1837
1840
|
colData = this._grid.setColumnData(idx, {});
|
1838
1841
|
}
|
1839
1842
|
colData[COL_DEF] = colDef;
|
1840
|
-
|
1843
|
+
let userModel = colDef.getUserModel();
|
1841
1844
|
// binding
|
1842
1845
|
this._grid.setColumnDataBindingHandler(idx, colDef.getRenderer());
|
1843
1846
|
// width and scalable
|
1844
|
-
|
1847
|
+
let value = userModel["width"];
|
1845
1848
|
// eslint-disable-next-line no-undefined
|
1846
1849
|
if(value !== undefined) {
|
1847
1850
|
value = +value;
|
1848
|
-
|
1851
|
+
let scalable;
|
1849
1852
|
if(userModel["scalable"] != null) {
|
1850
1853
|
scalable = userModel["scalable"] ? true : false;
|
1851
1854
|
} else {
|
@@ -1881,16 +1884,16 @@ Grid.prototype._onColumnAdded = function(e) {
|
|
1881
1884
|
}
|
1882
1885
|
|
1883
1886
|
// className
|
1884
|
-
|
1887
|
+
let i, classes = colDef.getClasses();
|
1885
1888
|
for(i = 0; i < classes.length; i++) {
|
1886
1889
|
this._grid.enableColumnClass(idx, classes[i]);
|
1887
1890
|
}
|
1888
|
-
|
1891
|
+
let colField = colDef.getField();
|
1889
1892
|
this._grid.setDataColumnName(idx, ROW_DEF); // This make ColumnDefinition renderer work
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1893
|
+
let fields = colDef.getAllFields();
|
1894
|
+
let referrer = colDef.getId();
|
1895
|
+
let len = fields.length;
|
1896
|
+
let field, dataType, prom, onLoaded;
|
1894
1897
|
for(i = 0; i < len; i++) {
|
1895
1898
|
field = fields[i];
|
1896
1899
|
if(this._shouldLoadFieldInfo(field)) {
|
@@ -1928,12 +1931,12 @@ Grid.prototype._onColumnAdded = function(e) {
|
|
1928
1931
|
* @see {@link Grid#removeAllColumns}
|
1929
1932
|
*/
|
1930
1933
|
Grid.prototype.removeColumn = function(colRef) {
|
1931
|
-
|
1934
|
+
let colIndex = this.getColumnIndex(colRef);
|
1932
1935
|
if(colIndex < 0) {
|
1933
1936
|
return;
|
1934
1937
|
}
|
1935
1938
|
|
1936
|
-
|
1939
|
+
let colDef = this.getColumnDefinition(colIndex);
|
1937
1940
|
|
1938
1941
|
if(!colDef.isRealTimeField()) {
|
1939
1942
|
if(this._dc) {
|
@@ -1954,8 +1957,8 @@ Grid.prototype.removeColumn = function(colRef) {
|
|
1954
1957
|
* @see {@link Grid#removeAllColumns}
|
1955
1958
|
*/
|
1956
1959
|
Grid.prototype.removeColumns = function(colRefs) {
|
1957
|
-
|
1958
|
-
|
1960
|
+
let indices = this.getColumnIndices(colRefs);
|
1961
|
+
let len = indices.length;
|
1959
1962
|
if(len <= 1) {
|
1960
1963
|
if(len === 1) {
|
1961
1964
|
this.removeColumn(indices[0]);
|
@@ -1964,12 +1967,12 @@ Grid.prototype.removeColumns = function(colRefs) {
|
|
1964
1967
|
}
|
1965
1968
|
indices.sort(Grid._descendingOrder); // Removal must be done from the back
|
1966
1969
|
|
1967
|
-
|
1968
|
-
|
1970
|
+
let staticFields = []; // For clearing any data stored in our cache
|
1971
|
+
let prevState = this._grid.freezeLayout(); // To prevent multiple UI updates
|
1969
1972
|
|
1970
|
-
for(
|
1971
|
-
|
1972
|
-
|
1973
|
+
for(let i = 0; i < len; ++i) {
|
1974
|
+
let colIndex = indices[i];
|
1975
|
+
let colDef = this.getColumnDefinition(colIndex);
|
1973
1976
|
if(!colDef.isRealTimeField()) {
|
1974
1977
|
staticFields.push(colDef.getField());
|
1975
1978
|
}
|
@@ -1991,7 +1994,7 @@ Grid.prototype.removeColumns = function(colRefs) {
|
|
1991
1994
|
* @see {@link Grid#removeColumns}
|
1992
1995
|
*/
|
1993
1996
|
Grid.prototype.removeAllColumns = function() {
|
1994
|
-
|
1997
|
+
let colCount = this.getColumnCount();
|
1995
1998
|
if(colCount <= 0) {
|
1996
1999
|
return;
|
1997
2000
|
}
|
@@ -1999,10 +2002,10 @@ Grid.prototype.removeAllColumns = function() {
|
|
1999
2002
|
if(!this._sharedSorter) {
|
2000
2003
|
this.clearSort();
|
2001
2004
|
}
|
2002
|
-
for(
|
2005
|
+
for(let i = colCount; --i >= 0;) {
|
2003
2006
|
// WARNING: This may affect plugins event listeners
|
2004
2007
|
this._grid.setColumnDataBindingHandler(i, null);
|
2005
|
-
|
2008
|
+
let colDef = this.getColumnDefinition(i);
|
2006
2009
|
colDef.dispose();
|
2007
2010
|
}
|
2008
2011
|
// TODO: Remove fields that are related to the column (e.g. fields for coloring)
|
@@ -2062,7 +2065,7 @@ Grid.prototype.reorderColumns = function (colRefs, destCol) {
|
|
2062
2065
|
* @see {@link Grid#showAllColumns}
|
2063
2066
|
*/
|
2064
2067
|
Grid.prototype.hideColumn = function(colRef, hidden) {
|
2065
|
-
|
2068
|
+
let colIndex = this.getColumnIndex(colRef);
|
2066
2069
|
if(colIndex < 0) { // not found
|
2067
2070
|
return;
|
2068
2071
|
}
|
@@ -2107,9 +2110,9 @@ Grid.prototype.addDataFields = function(fieldRef, referrer) {
|
|
2107
2110
|
return false;
|
2108
2111
|
}
|
2109
2112
|
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
+
let fields = Array.isArray(fieldRef) ? fieldRef : [fieldRef];
|
2114
|
+
let len = fields.length;
|
2115
|
+
let i, field, dataType, prom, onLoaded;
|
2113
2116
|
for(i = 0; i < len; i++) {
|
2114
2117
|
field = fields[i];
|
2115
2118
|
if(this._shouldLoadFieldInfo(field)) {
|
@@ -2166,7 +2169,7 @@ Grid.prototype.sortColumn = function(colRef, opt_order) {
|
|
2166
2169
|
return;
|
2167
2170
|
}
|
2168
2171
|
|
2169
|
-
|
2172
|
+
let colIndex = this.getColumnIndex(colRef);
|
2170
2173
|
if(colIndex < 0) {
|
2171
2174
|
this._stp.sortColumn(this.getSortedColumnIndex(), "n"); // reset current sorting
|
2172
2175
|
} else {
|
@@ -2178,7 +2181,7 @@ Grid.prototype.sortColumn = function(colRef, opt_order) {
|
|
2178
2181
|
* @param {string} str
|
2179
2182
|
*/
|
2180
2183
|
Grid.prototype.setColumnName = function(colIndex, str) {
|
2181
|
-
|
2184
|
+
let colDef = this.getColumnDefinition(colIndex);
|
2182
2185
|
if(colDef) {
|
2183
2186
|
colDef.setName(str);
|
2184
2187
|
this.updateColumnTitle();
|
@@ -2189,7 +2192,7 @@ Grid.prototype.setColumnName = function(colIndex, str) {
|
|
2189
2192
|
* @param {Function=} func
|
2190
2193
|
*/
|
2191
2194
|
Grid.prototype.setColumnRenderer = function(colRef, func) {
|
2192
|
-
|
2195
|
+
let colIndex = this.getColumnIndex(colRef);
|
2193
2196
|
this.setColumnFormatter(colIndex, func);
|
2194
2197
|
};
|
2195
2198
|
|
@@ -2199,10 +2202,10 @@ Grid.prototype.setColumnRenderer = function(colRef, func) {
|
|
2199
2202
|
* @param {Function=} func If not specified the renderer which corresponded id from mapping will be picked up
|
2200
2203
|
*/
|
2201
2204
|
Grid.prototype.activateColumnRenderer = function(colRef, id, func) {
|
2202
|
-
|
2205
|
+
let colIndex = this.getColumnIndex(colRef);
|
2203
2206
|
if (colIndex == null) { return; }
|
2204
2207
|
|
2205
|
-
|
2208
|
+
let colDef = this.getColumnDefinition(colIndex);
|
2206
2209
|
if(!colDef) { return; }
|
2207
2210
|
|
2208
2211
|
colDef.activateRenderer(id, func);
|
@@ -2219,12 +2222,12 @@ Grid.prototype.activateColumnRenderer = function(colRef, id, func) {
|
|
2219
2222
|
Grid.prototype.setColumnFormatter = function (colIndex, formatter) {
|
2220
2223
|
if (colIndex == null) { return; }
|
2221
2224
|
|
2222
|
-
|
2225
|
+
let colDef = this.getColumnDefinition(colIndex);
|
2223
2226
|
if(!colDef) {
|
2224
2227
|
return;
|
2225
2228
|
}
|
2226
2229
|
|
2227
|
-
|
2230
|
+
let func = null;
|
2228
2231
|
if (formatter) {
|
2229
2232
|
if(typeof formatter === "object") {
|
2230
2233
|
if(typeof formatter.init === "function") { // Initialize predefined formatter
|
@@ -2241,8 +2244,8 @@ Grid.prototype.setColumnFormatter = function (colIndex, formatter) {
|
|
2241
2244
|
}
|
2242
2245
|
|
2243
2246
|
if(func !== colDef.getRenderer()) {
|
2244
|
-
|
2245
|
-
|
2247
|
+
let section = this._grid.getSection("content");
|
2248
|
+
let col = /** @type {Column} */section.getColumn(colIndex);
|
2246
2249
|
if (col) {
|
2247
2250
|
col.clearContent();
|
2248
2251
|
}
|
@@ -2261,12 +2264,12 @@ Grid.prototype.setColumnFormatter = function (colIndex, formatter) {
|
|
2261
2264
|
* @param {ColumnDefinition~SortLogic=} func
|
2262
2265
|
*/
|
2263
2266
|
Grid.prototype.setColumnSorter = function(colRef, func) {
|
2264
|
-
|
2265
|
-
|
2267
|
+
let colIndex = this.getColumnIndex(colRef);
|
2268
|
+
let colDef = this.getColumnDefinition(colIndex);
|
2266
2269
|
if(colDef) {
|
2267
2270
|
colDef.setSorter(func);
|
2268
2271
|
|
2269
|
-
|
2272
|
+
let sortedColumn = this.getSortedColumnIndex(); // TODO: Support multi-column sorting
|
2270
2273
|
if(sortedColumn === colIndex) {
|
2271
2274
|
this._stp.refresh();
|
2272
2275
|
}
|
@@ -2279,8 +2282,8 @@ Grid.prototype.setColumnSorter = function(colRef, func) {
|
|
2279
2282
|
* @param {RowDefinition} rowDef
|
2280
2283
|
*/
|
2281
2284
|
Grid.prototype._initDuplicateRicData = function(rowDef) {
|
2282
|
-
|
2283
|
-
|
2285
|
+
let ric = rowDef.getSymbol();
|
2286
|
+
let rowDefs = this._connector.getRowDefByRic(ric);
|
2284
2287
|
if(rowDefs && rowDefs.length) {
|
2285
2288
|
cloneRowData(rowDefs[0], rowDef);
|
2286
2289
|
}
|
@@ -2290,7 +2293,7 @@ Grid.prototype._initDuplicateRicData = function(rowDef) {
|
|
2290
2293
|
* @param {Grid~RowReference=} rowRef Reference (i.e. row index, row id, or row definition) of the insert position
|
2291
2294
|
* @returns {RowDefinition}
|
2292
2295
|
* @example
|
2293
|
-
*
|
2296
|
+
* let grid = new rt.Grid(grid_div, options);
|
2294
2297
|
* grid.insertRow({"ric": "RIC"}, 0); // A new row is added at the top
|
2295
2298
|
*/
|
2296
2299
|
Grid.prototype.insertRow = function(rowOption, rowRef) {
|
@@ -2307,7 +2310,7 @@ Grid.prototype.insertRow = function(rowOption, rowRef) {
|
|
2307
2310
|
}
|
2308
2311
|
}
|
2309
2312
|
}
|
2310
|
-
|
2313
|
+
let rowDef = new RowDefinition(rowOption);
|
2311
2314
|
rowDef.setDataSource(this._dc); // This could also subscribe chain index/ric to JET/RTK
|
2312
2315
|
this._initDuplicateRicData(rowDef);
|
2313
2316
|
|
@@ -2323,7 +2326,7 @@ Grid.prototype.insertRow = function(rowOption, rowRef) {
|
|
2323
2326
|
* @param {Grid~RowReference=} rowRef Reference (i.e. row index, row id, or row definition) of the insert position
|
2324
2327
|
* @param {Array.<string>=} opt_fields
|
2325
2328
|
* @example
|
2326
|
-
*
|
2329
|
+
* let grid = new rt.Grid(grid_div, options);
|
2327
2330
|
* grid.insertRows([
|
2328
2331
|
* {ric: "RIC"},
|
2329
2332
|
* {values: {"field1": 0, "field2": 1}},
|
@@ -2340,12 +2343,12 @@ Grid.prototype.insertRows = function(rowOptions, rowRef, opt_fields) {
|
|
2340
2343
|
return;
|
2341
2344
|
}
|
2342
2345
|
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
|
2347
|
-
for(
|
2348
|
-
|
2346
|
+
let prevState = this._dt.freeze(); // Avoid sorting for each inserted row
|
2347
|
+
let fields = opt_fields || this.getColumnFields();
|
2348
|
+
let rowId = this._getRowId(rowRef);
|
2349
|
+
let len = rowOptions.length;
|
2350
|
+
for(let r = 0; r < len; ++r) {
|
2351
|
+
let rowOption = rowOptions[r];
|
2349
2352
|
if(rowOption) {
|
2350
2353
|
if(typeof rowOption === "string") {
|
2351
2354
|
rowOption = { "ric": rowOption };
|
@@ -2363,7 +2366,7 @@ Grid.prototype.insertRows = function(rowOptions, rowRef, opt_fields) {
|
|
2363
2366
|
* @see {@link Grid#logDV}
|
2364
2367
|
* @see {@link Grid#logDT}
|
2365
2368
|
* @example
|
2366
|
-
*
|
2369
|
+
* let grid = new rt.Grid(grid_div, options);
|
2367
2370
|
* grid.addStaticDataRows([
|
2368
2371
|
* [10, "a", true],
|
2369
2372
|
* [20, "b", false],
|
@@ -2384,7 +2387,7 @@ Grid.prototype.addStaticDataRows = function(dataRows, fields) {
|
|
2384
2387
|
}
|
2385
2388
|
|
2386
2389
|
if(!Array.isArray(dataRows)) {
|
2387
|
-
|
2390
|
+
let userObj = dataRows;
|
2388
2391
|
dataRows = null;
|
2389
2392
|
if(userObj) {
|
2390
2393
|
if(userObj.fields && !fields) {
|
@@ -2448,13 +2451,15 @@ Grid.prototype.updateDataSet = function(records, rowIdentifier) {
|
|
2448
2451
|
}
|
2449
2452
|
|
2450
2453
|
// Map new data index
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
2456
|
-
|
2454
|
+
let recordCount = records.length;
|
2455
|
+
let fieldSorting = "ROW_ORDER"; // TODO: Should be config by options
|
2456
|
+
let oldDataMap = {};
|
2457
|
+
let rowDef, id, record, i;
|
2458
|
+
let rowDefs = this.getAllRowDefinitions(); // Include the filter/hidden rows
|
2459
|
+
let rowDefCount = rowDefs.length;
|
2460
|
+
let prevState = false;
|
2457
2461
|
if(rowIdentifier) {
|
2462
|
+
prevState = this._dt.freeze();
|
2458
2463
|
for (i = 0; i < rowDefCount; i++) {
|
2459
2464
|
rowDef = rowDefs[i];
|
2460
2465
|
if(rowDef) {
|
@@ -2467,8 +2472,8 @@ Grid.prototype.updateDataSet = function(records, rowIdentifier) {
|
|
2467
2472
|
}
|
2468
2473
|
}
|
2469
2474
|
|
2470
|
-
|
2471
|
-
|
2475
|
+
let idMap = {};
|
2476
|
+
let newDataMap = {};
|
2472
2477
|
for (i = recordCount - 1; i >= 0; i--) {
|
2473
2478
|
record = records[i];
|
2474
2479
|
id = record[rowIdentifier];
|
@@ -2486,13 +2491,17 @@ Grid.prototype.updateDataSet = function(records, rowIdentifier) {
|
|
2486
2491
|
}
|
2487
2492
|
}
|
2488
2493
|
// Check Remove previous data
|
2489
|
-
for (
|
2494
|
+
for (let rowIdentifierName in oldDataMap) {
|
2490
2495
|
if (oldDataMap[rowIdentifierName] && !newDataMap[rowIdentifierName]) {
|
2491
2496
|
this.removeRow(oldDataMap[rowIdentifierName]); // Slow
|
2492
2497
|
}
|
2493
2498
|
}
|
2494
2499
|
this._dt.sortOnce(ROW_DEF, "a", compareNumber, fieldSorting);
|
2500
|
+
this._dt.freeze(prevState);
|
2495
2501
|
} else {
|
2502
|
+
if(recordCount - rowDefCount > 1 || rowDefCount - recordCount > 1) {
|
2503
|
+
prevState = this._dt.freeze();
|
2504
|
+
}
|
2496
2505
|
for (i = 0; i < rowDefCount; i++) {
|
2497
2506
|
record = records[i];
|
2498
2507
|
if(record) {
|
@@ -2511,6 +2520,9 @@ Grid.prototype.updateDataSet = function(records, rowIdentifier) {
|
|
2511
2520
|
rowDef.setRowData(record);
|
2512
2521
|
}
|
2513
2522
|
}
|
2523
|
+
if(recordCount - rowDefCount > 1 || rowDefCount - recordCount > 1) {
|
2524
|
+
this._dt.freeze(prevState);
|
2525
|
+
}
|
2514
2526
|
}
|
2515
2527
|
};
|
2516
2528
|
/** @private
|
@@ -2530,7 +2542,7 @@ Grid.prototype.removeRow = function(rowRef) {
|
|
2530
2542
|
if(this._mainGrid) {
|
2531
2543
|
return this._mainGrid.removeRow(this._getRowId(rowRef));
|
2532
2544
|
}
|
2533
|
-
|
2545
|
+
let rowDef = this._getRowDefinitionByRef(rowRef);
|
2534
2546
|
if(rowDef) {
|
2535
2547
|
if(!rowDef.isAutoGenerated()) { // Users cannot remove auto-generated row by themselves
|
2536
2548
|
this._removeRow(rowDef);
|
@@ -2546,7 +2558,7 @@ Grid.prototype.removeRow = function(rowRef) {
|
|
2546
2558
|
* @see {@link Grid#removeAllRows}
|
2547
2559
|
*/
|
2548
2560
|
Grid.prototype.removeRows = function(rowRefs) {
|
2549
|
-
|
2561
|
+
let rowDef;
|
2550
2562
|
if(!Array.isArray(rowRefs)) {
|
2551
2563
|
rowDef = this.removeRow(rowRefs);
|
2552
2564
|
return rowDef ? [rowDef] : [];
|
@@ -2555,9 +2567,9 @@ Grid.prototype.removeRows = function(rowRefs) {
|
|
2555
2567
|
return this._mainGrid.removeRows(rowRefs.map(this._getRowId));
|
2556
2568
|
}
|
2557
2569
|
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2570
|
+
let i;
|
2571
|
+
let rowDefs = [];
|
2572
|
+
let len = rowRefs.length;
|
2561
2573
|
|
2562
2574
|
// Verify user input
|
2563
2575
|
for(i = 0; i < len; ++i) {
|
@@ -2570,7 +2582,7 @@ Grid.prototype.removeRows = function(rowRefs) {
|
|
2570
2582
|
}
|
2571
2583
|
len = rowDefs.length;
|
2572
2584
|
|
2573
|
-
|
2585
|
+
let prevState = false;
|
2574
2586
|
if(len > 1) {
|
2575
2587
|
prevState = this._dt.freeze(); // Prevent multiple changes that trigger sorting and filtering
|
2576
2588
|
}
|
@@ -2595,7 +2607,7 @@ Grid.prototype.removeAllRows = function() {
|
|
2595
2607
|
if(!this._dt.getRowCount()) {
|
2596
2608
|
return;
|
2597
2609
|
}
|
2598
|
-
|
2610
|
+
let rowDefs = this._getAllRowDefinitions();
|
2599
2611
|
|
2600
2612
|
if(!this._sharedDataSource) {
|
2601
2613
|
this._dc.clearAllData();
|
@@ -2623,14 +2635,14 @@ Grid.prototype._removeRow = function(rowDef) {
|
|
2623
2635
|
}
|
2624
2636
|
this._dispatch("beforeRowRemoved", {});
|
2625
2637
|
|
2626
|
-
|
2627
|
-
|
2628
|
-
|
2638
|
+
let connector = this._connector;
|
2639
|
+
let dt = this._dt;
|
2640
|
+
let childRowDefs = rowDef.getDescendants(); // TODO: Support nested child
|
2629
2641
|
if(childRowDefs) { // Remove all children first
|
2630
|
-
for(
|
2642
|
+
for(let i = 0; i < childRowDefs.length; i++) {
|
2631
2643
|
connector.removeRic(childRowDefs[i]);
|
2632
2644
|
}
|
2633
|
-
|
2645
|
+
let rowIds = childRowDefs.map(RowDefinition.toRowId);
|
2634
2646
|
dt.removeRows(rowIds);
|
2635
2647
|
}
|
2636
2648
|
connector.removeRic(rowDef);
|
@@ -2643,8 +2655,8 @@ Grid.prototype._removeRow = function(rowDef) {
|
|
2643
2655
|
* @param {boolean=} hidden if false, show instead of hide
|
2644
2656
|
*/
|
2645
2657
|
Grid.prototype.hideRow = function(rowRef, hidden) {
|
2646
|
-
|
2647
|
-
|
2658
|
+
let rid = this._getRowId(rowRef);
|
2659
|
+
let grid = this._mainGrid || this._grid;
|
2648
2660
|
grid.hideRow(rid, hidden);
|
2649
2661
|
};
|
2650
2662
|
|
@@ -2657,8 +2669,8 @@ Grid.prototype.hideRows = function (rowRefs, hidden) {
|
|
2657
2669
|
if (!Array.isArray(rowRefs)) {
|
2658
2670
|
rowRefs = [rowRefs];
|
2659
2671
|
}
|
2660
|
-
|
2661
|
-
|
2672
|
+
let rids = rowRefs.map(this._getRowId);
|
2673
|
+
let grid = this._mainGrid || this._grid;
|
2662
2674
|
grid.hideRows(rids, hidden);
|
2663
2675
|
};
|
2664
2676
|
/**
|
@@ -2696,19 +2708,19 @@ Grid.prototype.setRic = function(rowRef, str, options) {
|
|
2696
2708
|
this._mainGrid.setRic(this._toRowId(rowRef), str, options);
|
2697
2709
|
return;
|
2698
2710
|
}
|
2699
|
-
|
2711
|
+
let rowDef = this._getRowDefinitionByRef(rowRef);
|
2700
2712
|
if(rowDef) {
|
2701
2713
|
options = options || {};
|
2702
2714
|
options["ric"] = str;
|
2703
|
-
|
2704
|
-
|
2715
|
+
let extractedOptions = RowDefinition.extractRowOptions(options);
|
2716
|
+
let oldRic = rowDef.getSymbol();
|
2705
2717
|
if(rowDef.setContent(str, extractedOptions)) { // The given string may not be a RIC
|
2706
2718
|
this._connector.removeRic(rowDef, oldRic);
|
2707
2719
|
this._initDuplicateRicData(rowDef);
|
2708
2720
|
this._connector.addRic(rowDef);
|
2709
2721
|
}
|
2710
2722
|
|
2711
|
-
|
2723
|
+
let values = options["values"];
|
2712
2724
|
if(values != null) {
|
2713
2725
|
rowDef.setStaticRowData(values, options["fields"]);
|
2714
2726
|
}
|
@@ -2724,7 +2736,7 @@ Grid.prototype.setRic = function(rowRef, str, options) {
|
|
2724
2736
|
* @param {Grid~RowReference} rowRef
|
2725
2737
|
*/
|
2726
2738
|
Grid.prototype.unlinkChain = function(rowRef) {
|
2727
|
-
|
2739
|
+
let rowDef = this._getRowDefinitionByRef(rowRef);
|
2728
2740
|
if(!rowDef) {
|
2729
2741
|
return;
|
2730
2742
|
}
|
@@ -2763,7 +2775,7 @@ Grid.prototype._onRowExpansionBinding = function(e) {
|
|
2763
2775
|
}
|
2764
2776
|
|
2765
2777
|
if(e["originalRowId"]) {
|
2766
|
-
|
2778
|
+
let rowIndex = this._dv.getRowIndex(e["originalRowId"]);
|
2767
2779
|
e["originalRowDef"] = this._getRowDefinitionByIndex(rowIndex);
|
2768
2780
|
e["originalRowData"] = e["originalRowDef"].getRowData();
|
2769
2781
|
} else {
|
@@ -2817,7 +2829,7 @@ Grid.prototype.getColumnCount = function() {
|
|
2817
2829
|
* @return {string}
|
2818
2830
|
*/
|
2819
2831
|
Grid.prototype.getColumnDataType = function(colIndex) {
|
2820
|
-
|
2832
|
+
let colDef = this.getColumnDefinition(colIndex);
|
2821
2833
|
if (colDef) {
|
2822
2834
|
return colDef.getDataType();
|
2823
2835
|
}
|
@@ -2828,7 +2840,7 @@ Grid.prototype.getColumnDataType = function(colIndex) {
|
|
2828
2840
|
* @return {ColumnDefinition}
|
2829
2841
|
*/
|
2830
2842
|
Grid.prototype.getColumnDefinition = function(colIndex) {
|
2831
|
-
|
2843
|
+
let colData = this._grid.getColumnData(colIndex);
|
2832
2844
|
if(colData) {
|
2833
2845
|
return /** @type{ColumnDefinition} */(colData[COL_DEF]) || null;
|
2834
2846
|
}
|
@@ -2838,9 +2850,9 @@ Grid.prototype.getColumnDefinition = function(colIndex) {
|
|
2838
2850
|
* @return {!Array.<ColumnDefinition>}
|
2839
2851
|
*/
|
2840
2852
|
Grid.prototype.getColumnDefinitions = function() {
|
2841
|
-
|
2842
|
-
|
2843
|
-
for(
|
2853
|
+
let colCount = this.getColumnCount();
|
2854
|
+
let colDefs = new Array(colCount);
|
2855
|
+
for(let i = 0; i < colCount; i++) {
|
2844
2856
|
colDefs[i] = this.getColumnDefinition(i);
|
2845
2857
|
}
|
2846
2858
|
return colDefs;
|
@@ -2862,10 +2874,10 @@ Grid.prototype.getColumnDefinitionById = function(colId) {
|
|
2862
2874
|
* @return {ColumnDefinition}
|
2863
2875
|
*/
|
2864
2876
|
Grid.prototype.getColumnDefinitionsById = function(colIds) {
|
2865
|
-
|
2877
|
+
let colCount = Array.isArray(colIds) ? colIds.length : 0;
|
2866
2878
|
if(colCount > 0) {
|
2867
|
-
|
2868
|
-
|
2879
|
+
let i, colId;
|
2880
|
+
let colDefs = new Array(colCount);
|
2869
2881
|
for(i = 0; i < colCount; i++) {
|
2870
2882
|
colId = colIds[i];
|
2871
2883
|
colDefs[i] = this.getColumnDefinitionById(colId);
|
@@ -2885,9 +2897,9 @@ Grid.prototype._getColumnDefinition = function(colRef) {
|
|
2885
2897
|
} else if(typeof colRef === "number") {
|
2886
2898
|
return this.getColumnDefinition(colRef);
|
2887
2899
|
} else if(typeof colRef === "string") {
|
2888
|
-
|
2889
|
-
for(
|
2890
|
-
|
2900
|
+
let colCount = this.getColumnCount();
|
2901
|
+
for(let i = 0; i < colCount; ++i) {
|
2902
|
+
let colDef = this.getColumnDefinition(i);
|
2891
2903
|
if(_hasFieldOrId(colDef, colRef)) {
|
2892
2904
|
return colDef; // Return the first found column
|
2893
2905
|
}
|
@@ -2900,7 +2912,7 @@ Grid.prototype._getColumnDefinition = function(colRef) {
|
|
2900
2912
|
* @return {string}
|
2901
2913
|
*/
|
2902
2914
|
Grid.prototype.getRowType = function(rowRef) {
|
2903
|
-
|
2915
|
+
let rowDef = this.getRowDefinition(rowRef);
|
2904
2916
|
return rowDef ? rowDef.getType() : "";
|
2905
2917
|
};
|
2906
2918
|
/** Get RowDefinition object by either number or row id
|
@@ -2992,15 +3004,15 @@ Grid.prototype.getMultipleRowData = function(obj) {
|
|
2992
3004
|
if(typeof obj === "number") {
|
2993
3005
|
return [this.getRowData(obj)];
|
2994
3006
|
}
|
2995
|
-
|
3007
|
+
let rowDefs = null;
|
2996
3008
|
if(Array.isArray(obj)) {
|
2997
|
-
|
2998
|
-
|
2999
|
-
|
3009
|
+
let rowRefs = obj;
|
3010
|
+
let rowCount = rowRefs.length;
|
3011
|
+
let rows = new Array(rowCount);
|
3000
3012
|
rowDefs = this.getRowDefinitions();
|
3001
3013
|
|
3002
|
-
for(
|
3003
|
-
|
3014
|
+
for(let r = 0; r < rowCount; ++r) {
|
3015
|
+
let rowRef = rowRefs[r];
|
3004
3016
|
if(typeof rowRef === "number") {
|
3005
3017
|
rows[r] = toRowData(rowDefs[rowRef]);
|
3006
3018
|
} else if(rowRef && rowRef.getRowData) {
|
@@ -3023,10 +3035,10 @@ Grid.prototype.getMultipleRowData = function(obj) {
|
|
3023
3035
|
* @param {Object} values {"FIELD1": value1, "FIELD2": value2, ...} Use null to remove current row data (not row in the view).
|
3024
3036
|
*/
|
3025
3037
|
Grid.prototype.setRicData = function(ric, values) {
|
3026
|
-
|
3027
|
-
|
3028
|
-
for (
|
3029
|
-
|
3038
|
+
let rowDefs = this._connector.getRowDefByRic(ric);
|
3039
|
+
let rowCount = rowDefs ? rowDefs.length : 0;
|
3040
|
+
for (let i = 0; i < rowCount; ++i) {
|
3041
|
+
let rowDef = rowDefs[i];
|
3030
3042
|
if (rowDef && rowDef.getSymbol() === ric) {
|
3031
3043
|
rowDef.setRowData(values); // TODO: Need conflator to improve performance
|
3032
3044
|
}
|
@@ -3038,7 +3050,7 @@ Grid.prototype.setRicData = function(ric, values) {
|
|
3038
3050
|
* @param {Object} values {"FIELD1": value1, "FIELD2": value2, ...} Use null to remove current row data (not row in the view).
|
3039
3051
|
*/
|
3040
3052
|
Grid.prototype.setRowData = function(rowRef, values) {
|
3041
|
-
|
3053
|
+
let rowDef = this._getRowDefinitionByRef(rowRef);
|
3042
3054
|
if(rowDef) {
|
3043
3055
|
rowDef.setRowData(values);
|
3044
3056
|
}
|
@@ -3050,7 +3062,7 @@ Grid.prototype.setRowData = function(rowRef, values) {
|
|
3050
3062
|
* @param {Object} values
|
3051
3063
|
*/
|
3052
3064
|
Grid.prototype.setStaticRowData = function(rowRef, values) {
|
3053
|
-
|
3065
|
+
let rowDef = this._getRowDefinitionByRef(rowRef);
|
3054
3066
|
if(rowDef) {
|
3055
3067
|
rowDef.setStaticRowData(values);
|
3056
3068
|
}
|
@@ -3063,7 +3075,7 @@ Grid.prototype.setStaticRowData = function(rowRef, values) {
|
|
3063
3075
|
* @param {*} value
|
3064
3076
|
*/
|
3065
3077
|
Grid.prototype.setStaticData = function(rowRef, field, value) {
|
3066
|
-
|
3078
|
+
let rowDef = this._getRowDefinitionByRef(rowRef);
|
3067
3079
|
if(rowDef) {
|
3068
3080
|
rowDef.setStaticData(field, value);
|
3069
3081
|
}
|
@@ -3091,9 +3103,9 @@ Grid.prototype._getRowId = function(rowRef) {
|
|
3091
3103
|
Grid.prototype.getColumnIndex = function(colRef) {
|
3092
3104
|
if(colRef) {
|
3093
3105
|
if(colRef instanceof ColumnDefinition) {
|
3094
|
-
|
3095
|
-
for(
|
3096
|
-
|
3106
|
+
let colCount = this.getColumnCount();
|
3107
|
+
for(let i = 0; i < colCount; ++i) {
|
3108
|
+
let colDef = this.getColumnDefinition(i);
|
3097
3109
|
if(colDef === colRef) {
|
3098
3110
|
return i;
|
3099
3111
|
}
|
@@ -3109,13 +3121,13 @@ Grid.prototype.getColumnIndex = function(colRef) {
|
|
3109
3121
|
* @return {!Array.<number>}
|
3110
3122
|
*/
|
3111
3123
|
Grid.prototype.getColumnIndices = function(colRefs) {
|
3112
|
-
|
3113
|
-
|
3114
|
-
|
3115
|
-
|
3124
|
+
let ary = [];
|
3125
|
+
let colCount = this.getColumnCount();
|
3126
|
+
let inputAry = Array.isArray(colRefs) ? colRefs : [colRefs];
|
3127
|
+
let len = inputAry.length;
|
3116
3128
|
// Verify user input
|
3117
|
-
for(
|
3118
|
-
|
3129
|
+
for(let i = 0; i < len; ++i) {
|
3130
|
+
let colIndex = this.getColumnIndex(inputAry[i]);
|
3119
3131
|
if(colIndex >= 0 && colIndex < colCount) {
|
3120
3132
|
ary.push(colIndex); // WARNING: We have not checked for duplication
|
3121
3133
|
}
|
@@ -3190,11 +3202,11 @@ Grid.prototype.freezeColumn = function(colIndex, pinnedRightColumns) {
|
|
3190
3202
|
*/
|
3191
3203
|
Grid.prototype.pinColumn = function(colRef, side) {
|
3192
3204
|
if(Array.isArray(colRef)) {
|
3193
|
-
|
3194
|
-
|
3205
|
+
let ary = colRef;
|
3206
|
+
let len = ary.length;
|
3195
3207
|
|
3196
|
-
|
3197
|
-
for(
|
3208
|
+
let dirty = 0;
|
3209
|
+
for(let i = 0; i < len; ++i) {
|
3198
3210
|
dirty |= this._pinColumn(ary[i], side);
|
3199
3211
|
}
|
3200
3212
|
return dirty ? true : false;
|
@@ -3207,18 +3219,18 @@ Grid.prototype.pinColumn = function(colRef, side) {
|
|
3207
3219
|
* @return {boolean}
|
3208
3220
|
*/
|
3209
3221
|
Grid.prototype._pinColumn = function(colRef, side) {
|
3210
|
-
|
3211
|
-
|
3222
|
+
let colIndex = this.getColumnIndex(colRef);
|
3223
|
+
let colCount = this.getColumnCount();
|
3212
3224
|
if(colIndex < 0 || colIndex > colCount) {
|
3213
3225
|
return false;
|
3214
3226
|
}
|
3215
3227
|
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3228
|
+
let leftPinnedCount = this._grid.getPinnedLeftColumnCount();
|
3229
|
+
let rightPinnedCount = this._grid.getPinnedRightColumnCount();
|
3230
|
+
let stationaryIdx = this._grid.getStationaryColumnIndex();
|
3219
3231
|
|
3220
3232
|
if(side && side.toLowerCase() === "right") {
|
3221
|
-
|
3233
|
+
let rightPinnedIndex = this._grid.getFirstPinnedRightIndex();
|
3222
3234
|
if(colIndex >= rightPinnedIndex) {
|
3223
3235
|
return false; // The column is already pinned area
|
3224
3236
|
}
|
@@ -3257,11 +3269,11 @@ Grid.prototype._pinColumn = function(colRef, side) {
|
|
3257
3269
|
*/
|
3258
3270
|
Grid.prototype.unpinColumn = function(colRef, dest) {
|
3259
3271
|
if(Array.isArray(colRef)) {
|
3260
|
-
|
3261
|
-
|
3272
|
+
let ary = colRef;
|
3273
|
+
let len = ary.length;
|
3262
3274
|
|
3263
|
-
|
3264
|
-
for(
|
3275
|
+
let dirty = 0;
|
3276
|
+
for(let i = len; --i >= 0;) { // WARNING: unpinning is done in reversed order
|
3265
3277
|
dirty |= this._unpinColumn(ary[i], dest);
|
3266
3278
|
}
|
3267
3279
|
return dirty ? true : false;
|
@@ -3274,29 +3286,29 @@ Grid.prototype.unpinColumn = function(colRef, dest) {
|
|
3274
3286
|
* @return {boolean}
|
3275
3287
|
*/
|
3276
3288
|
Grid.prototype._unpinColumn = function(colRef, dest) {
|
3277
|
-
|
3289
|
+
let colIndex = this.getColumnIndex(colRef);
|
3278
3290
|
if(colIndex < 0) {
|
3279
3291
|
return false;
|
3280
3292
|
}
|
3281
3293
|
|
3282
|
-
|
3283
|
-
|
3284
|
-
|
3285
|
-
|
3294
|
+
let leftPinnedCount = this._grid.getPinnedLeftColumnCount();
|
3295
|
+
let rightPinnedCount = this._grid.getPinnedRightColumnCount();
|
3296
|
+
let colCount = this.getColumnCount();
|
3297
|
+
let firstRightPinnedIndex = colCount - rightPinnedCount;
|
3286
3298
|
|
3287
3299
|
if(colIndex >= leftPinnedCount && colIndex < firstRightPinnedIndex) {
|
3288
3300
|
return false;
|
3289
3301
|
}
|
3290
3302
|
|
3291
|
-
|
3292
|
-
|
3303
|
+
let srcId = null;
|
3304
|
+
let destId = null;
|
3293
3305
|
if(dest != null) {
|
3294
|
-
|
3306
|
+
let destIdx = this.getColumnIndex(dest);
|
3295
3307
|
destId = this.getColumnId(destIdx);
|
3296
3308
|
srcId = this.getColumnId(colIndex);
|
3297
3309
|
}
|
3298
3310
|
|
3299
|
-
|
3311
|
+
let stationaryIdx = this._grid.getStationaryColumnIndex();
|
3300
3312
|
|
3301
3313
|
if(colIndex < leftPinnedCount) {
|
3302
3314
|
if(colIndex > stationaryIdx) {
|
@@ -3325,8 +3337,8 @@ Grid.prototype._unpinColumn = function(colRef, dest) {
|
|
3325
3337
|
* @return {boolean}
|
3326
3338
|
*/
|
3327
3339
|
Grid.prototype.unpinAllColumns = function() {
|
3328
|
-
|
3329
|
-
|
3340
|
+
let leftPinnedCount = this._grid.getPinnedLeftColumnCount();
|
3341
|
+
let rightPinnedCount = this._grid.getPinnedRightColumnCount();
|
3330
3342
|
if(!leftPinnedCount && !rightPinnedCount) {
|
3331
3343
|
return false;
|
3332
3344
|
}
|
@@ -3342,8 +3354,8 @@ Grid.prototype._onColumnHeaderBinding = function(e) {
|
|
3342
3354
|
return; // WARNING: Assume that only the first title section is owned by the grid. Anything else is assumed to be generated by plugins
|
3343
3355
|
}
|
3344
3356
|
|
3345
|
-
|
3346
|
-
|
3357
|
+
let c = e["fromColIndex"];
|
3358
|
+
let toC = e["toColIndex"];
|
3347
3359
|
while(c < toC) {
|
3348
3360
|
this._renderColumnHeader(c++, e);
|
3349
3361
|
}
|
@@ -3353,22 +3365,22 @@ Grid.prototype._onColumnHeaderBinding = function(e) {
|
|
3353
3365
|
* @param {Object} arg
|
3354
3366
|
*/
|
3355
3367
|
Grid.prototype._renderColumnHeader = function(colIndex, arg) {
|
3356
|
-
|
3368
|
+
let colDef = this.getColumnDefinition(colIndex);
|
3357
3369
|
if(!colDef) {
|
3358
3370
|
return;
|
3359
3371
|
}
|
3360
|
-
|
3361
|
-
|
3362
|
-
|
3372
|
+
let customRenderer = colDef.getHeaderRenderer();
|
3373
|
+
let tSection = arg.section;
|
3374
|
+
let rowCount = tSection.getRowCount();
|
3363
3375
|
arg["colIndex"] = colIndex;
|
3364
3376
|
arg["columnDef"] = colDef;
|
3365
3377
|
|
3366
|
-
|
3367
|
-
|
3368
|
-
|
3378
|
+
let colName = colDef.getName();
|
3379
|
+
let colTooltip = colDef.getTooltip();
|
3380
|
+
let headerAlignment = colDef.getHeaderAlignment();
|
3369
3381
|
|
3370
|
-
for(
|
3371
|
-
|
3382
|
+
for(let r = 0; r < rowCount; ++r) {
|
3383
|
+
let tCell = tSection.getCell(colIndex, r, false);
|
3372
3384
|
// Default behaviors
|
3373
3385
|
tCell.setContent(colName);
|
3374
3386
|
tCell.setTooltip(colTooltip);
|
@@ -3387,7 +3399,7 @@ Grid.prototype.updateColumnTitle = function() {
|
|
3387
3399
|
if(this._columnTitleConflator.conflate()) {
|
3388
3400
|
return;
|
3389
3401
|
}
|
3390
|
-
|
3402
|
+
let tss = this._grid.getSectionSettings("title"); // WARNING: Assume that only the first title section is owned by the grid
|
3391
3403
|
if(tss) {
|
3392
3404
|
tss.rerender();
|
3393
3405
|
}
|
@@ -3433,17 +3445,17 @@ Grid.prototype._onQuote2PostUpdate = function (e) {
|
|
3433
3445
|
* @param {!Object} e
|
3434
3446
|
*/
|
3435
3447
|
Grid.prototype._onDataChanged = function(e) {
|
3436
|
-
|
3448
|
+
let rowData = e["rowData"]; // Use rowData to retrieve corresponding subscription object
|
3437
3449
|
if (!rowData) {
|
3438
3450
|
return; // This must be a global change
|
3439
3451
|
}
|
3440
|
-
|
3452
|
+
let rowDef = rowData[ROW_DEF];
|
3441
3453
|
|
3442
3454
|
if(rowDef) {
|
3443
|
-
|
3455
|
+
let rowId = rowDef.getRowId();
|
3444
3456
|
if(rowId) {
|
3445
3457
|
// e["rid"] could be from JET/RTK (rowId + ric) or static data update (rowId)
|
3446
|
-
|
3458
|
+
let curRowData = this._dc.getRowData(e["rid"]);
|
3447
3459
|
if (curRowData) {
|
3448
3460
|
if(rowDef.addUpdate(e)) { // This is the only place that update array can grow. It is used for blinking data.
|
3449
3461
|
this._dt._hasNewUpdates = true; // Mark data table for cleaning it up later
|
@@ -3458,9 +3470,9 @@ Grid.prototype._onDataChanged = function(e) {
|
|
3458
3470
|
}
|
3459
3471
|
|
3460
3472
|
// The new data update has no row definition, meaning that we have found a new constituent from a chain.
|
3461
|
-
|
3473
|
+
let subId = rowData[SUB_ID]; // The constituent will share the same sub id as its parent
|
3462
3474
|
if(subId) {
|
3463
|
-
|
3475
|
+
let parentDef = this._getRowDefinitionById(subId);
|
3464
3476
|
if(parentDef && parentDef.getRic() !== rowData["RIC"]) { // TODO: Check for delayed ric
|
3465
3477
|
if(!this._chainMembers) {
|
3466
3478
|
this._chainMembers = {};
|
@@ -3480,21 +3492,21 @@ Grid.prototype._addMemberOfChain = function(rowData) {
|
|
3480
3492
|
return;
|
3481
3493
|
}
|
3482
3494
|
|
3483
|
-
|
3484
|
-
|
3485
|
-
|
3495
|
+
let rows = this._chainConflator.popAllData(); // This must have no duplication
|
3496
|
+
let len = rows ? rows.length : 0;
|
3497
|
+
let i;
|
3486
3498
|
|
3487
|
-
|
3499
|
+
let prevState = false;
|
3488
3500
|
if(len > 1) {
|
3489
3501
|
prevState = this._dt.freeze(); // Avoid sorting for each insertion
|
3490
3502
|
}
|
3491
|
-
|
3503
|
+
let childDefs = [];
|
3492
3504
|
for(i = 0; i < len; ++i) {
|
3493
3505
|
rowData = /** @type{!Object} */(rows[i]);
|
3494
|
-
|
3495
|
-
|
3506
|
+
let subId = rowData[SUB_ID];
|
3507
|
+
let parentDef = this._getRowDefinitionById(subId);
|
3496
3508
|
if(parentDef) {
|
3497
|
-
|
3509
|
+
let childDef = parentDef.addConstituent(/** @type{string} */(rowData["RIC"]), this._dt);
|
3498
3510
|
if(childDef) {
|
3499
3511
|
childDefs.push(childDef);
|
3500
3512
|
} // else { // childDef has already been added
|
@@ -3502,7 +3514,7 @@ Grid.prototype._addMemberOfChain = function(rowData) {
|
|
3502
3514
|
}
|
3503
3515
|
this._chainMembers = null; // Clear all waiting chain members
|
3504
3516
|
|
3505
|
-
|
3517
|
+
let childCount = childDefs.length;
|
3506
3518
|
if(childCount) {
|
3507
3519
|
for(i = childCount; --i >= 0;) {
|
3508
3520
|
this._connector.addRic(childDefs[i]); // TODO: JET/RTK should not re-subscribe this
|
@@ -3530,19 +3542,19 @@ Grid.prototype._updateStreamingData = function() {
|
|
3530
3542
|
* @param {Object} e
|
3531
3543
|
*/
|
3532
3544
|
Grid.prototype._onPreDataSorting = function (e) {
|
3533
|
-
|
3545
|
+
let objs = this._stp.getSortedColumns();
|
3534
3546
|
|
3535
3547
|
this._sorter.reset();
|
3536
3548
|
if(Array.isArray(objs)) {
|
3537
|
-
|
3538
|
-
for(
|
3539
|
-
|
3540
|
-
|
3541
|
-
|
3542
|
-
|
3543
|
-
|
3544
|
-
|
3545
|
-
|
3549
|
+
let sortCount = objs.length;
|
3550
|
+
for(let i = 0; i < sortCount; ++i) {
|
3551
|
+
let obj = objs[i];
|
3552
|
+
let field = obj["field"] || "";
|
3553
|
+
let colIndex = obj["colIndex"];
|
3554
|
+
let colDef = (colIndex >= 0) ? this.getColumnDefinition(colIndex) : null;
|
3555
|
+
|
3556
|
+
let rowSorting = false;
|
3557
|
+
let sortLogic = null;
|
3546
3558
|
if(colDef) {
|
3547
3559
|
field = colDef.getField(); // WARNING: Field and logic could be out of sync
|
3548
3560
|
rowSorting = colDef.isRowSorting();
|
@@ -3588,10 +3600,10 @@ Grid.prototype._clearDataUpdates = function() {
|
|
3588
3600
|
if(!this._dt || !this._dt._hasNewUpdates) {
|
3589
3601
|
return;
|
3590
3602
|
}
|
3591
|
-
|
3592
|
-
for(
|
3593
|
-
|
3594
|
-
|
3603
|
+
let rowIds = this._dt.getAllRowIds(true); // Use shallow copy for speed
|
3604
|
+
for(let i = rowIds.length; --i >= 0;) {
|
3605
|
+
let rowData = this._dt.getRowData(rowIds[i]);
|
3606
|
+
let rowDef = rowData[ROW_DEF];
|
3595
3607
|
rowDef.resetUpdates();
|
3596
3608
|
}
|
3597
3609
|
};
|
@@ -3639,7 +3651,7 @@ Grid.prototype.getPageCount = function() {
|
|
3639
3651
|
* @param {Grid~RowReference} rowRef
|
3640
3652
|
*/
|
3641
3653
|
Grid.prototype.toggleChain = function(rowRef) {
|
3642
|
-
|
3654
|
+
let rowDef = this._getRowDefinitionByRef(rowRef);
|
3643
3655
|
if(rowDef) {
|
3644
3656
|
rowDef.toggleChain();
|
3645
3657
|
}
|
@@ -3651,7 +3663,7 @@ Grid.prototype.toggleChain = function(rowRef) {
|
|
3651
3663
|
* @return {boolean}
|
3652
3664
|
*/
|
3653
3665
|
Grid.prototype.setClassification = function(rowRef, fields) {
|
3654
|
-
|
3666
|
+
let rowDef = this._getRowDefinitionByRef(rowRef);
|
3655
3667
|
if(rowDef) {
|
3656
3668
|
return this._dt.setSegmentClassification(rowDef.getRowId(), fields);
|
3657
3669
|
}
|
@@ -3676,7 +3688,7 @@ Grid.prototype.contains = function(elem) {
|
|
3676
3688
|
* @return {boolean}
|
3677
3689
|
*/
|
3678
3690
|
Grid.prototype.isFocused = function() {
|
3679
|
-
|
3691
|
+
let activeElement = document.activeElement;
|
3680
3692
|
if(!activeElement || !activeElement.shadowRoot) {
|
3681
3693
|
// active element is not in the shadow DOM. try using contains method to check
|
3682
3694
|
return this.contains(activeElement);
|
@@ -3743,17 +3755,17 @@ Grid.prototype._onFormulaDataRequired = function(e) {
|
|
3743
3755
|
* @param {Object} e
|
3744
3756
|
*/
|
3745
3757
|
Grid.prototype._onDataComposed = function(e) {
|
3746
|
-
|
3758
|
+
let values = e["changes"];
|
3747
3759
|
if(!values) {
|
3748
3760
|
return; // Cannot do data composition if there is no change in data
|
3749
3761
|
}
|
3750
3762
|
|
3751
|
-
|
3763
|
+
let rowData = e["rowData"];
|
3752
3764
|
if(!rowData) {
|
3753
3765
|
return; // Row could already be removed or global change event is sent
|
3754
3766
|
}
|
3755
3767
|
|
3756
|
-
|
3768
|
+
let rowDef = rowData[ROW_DEF];
|
3757
3769
|
if(!rowDef) {
|
3758
3770
|
return;
|
3759
3771
|
}
|
@@ -3762,7 +3774,7 @@ Grid.prototype._onDataComposed = function(e) {
|
|
3762
3774
|
}
|
3763
3775
|
|
3764
3776
|
if(this._autoDateConversion) { // auto data conversion
|
3765
|
-
|
3777
|
+
let field, value, dataType, colDef;
|
3766
3778
|
for(field in values) {
|
3767
3779
|
colDef = this._getColumnDefinition(field);
|
3768
3780
|
if(colDef) {
|
@@ -3792,16 +3804,16 @@ Grid.prototype._onDataComposed = function(e) {
|
|
3792
3804
|
* @param {Object} e
|
3793
3805
|
*/
|
3794
3806
|
Grid.prototype._onSubSegmentChanged = function(e) {
|
3795
|
-
|
3796
|
-
|
3797
|
-
|
3807
|
+
let insertionList = /** @type{Array.<Segment>} */(e["insertionList"]);
|
3808
|
+
let removalList = /** @type{Array.<string>} */(e["removalList"]);
|
3809
|
+
let removedRows = /** @type{Object} */(e["removedRows"]);
|
3798
3810
|
|
3799
|
-
|
3800
|
-
|
3801
|
-
|
3811
|
+
let i;
|
3812
|
+
let removalCount = removalList.length;
|
3813
|
+
let rowDef = null;
|
3802
3814
|
for(i = 0; i < removalCount; i++) {
|
3803
|
-
|
3804
|
-
|
3815
|
+
let rid = removalList[i];
|
3816
|
+
let removedRow = removedRows[rid];
|
3805
3817
|
if(removedRow) {
|
3806
3818
|
rowDef = removedRow[ROW_DEF];
|
3807
3819
|
if(rowDef) {
|
@@ -3811,11 +3823,11 @@ Grid.prototype._onSubSegmentChanged = function(e) {
|
|
3811
3823
|
}
|
3812
3824
|
}
|
3813
3825
|
|
3814
|
-
|
3826
|
+
let insertionCount = insertionList.length;
|
3815
3827
|
for(i = 0; i < insertionCount; i++) {
|
3816
|
-
|
3817
|
-
//
|
3818
|
-
|
3828
|
+
let segment = insertionList[i];
|
3829
|
+
// let parentId = segment.getParentId();
|
3830
|
+
let segmentId = segment.getId();
|
3819
3831
|
rowDef = new RowDefinition({
|
3820
3832
|
"segmentId": segmentId
|
3821
3833
|
});
|
@@ -3835,10 +3847,10 @@ Grid.prototype._recalculateFormulas = function(e) {
|
|
3835
3847
|
if(e && e["rid"]) {
|
3836
3848
|
this._fnEngine.calculate(/** @type{Object.<string, *>} */ (e["rowData"]), /** @type{Object.<string, *>} */ (e["changes"]));
|
3837
3849
|
} else {
|
3838
|
-
|
3850
|
+
let rows = this._dc ? this._dc.getAllRowData() : null; // Slow
|
3839
3851
|
|
3840
|
-
|
3841
|
-
for(
|
3852
|
+
let rowCount = rows ? rows.length : 0;
|
3853
|
+
for(let r = 0; r < rowCount; ++r) { // WARNING: This is very slow
|
3842
3854
|
this._fnEngine.calculate(rows[r]);
|
3843
3855
|
}
|
3844
3856
|
}
|
@@ -3850,11 +3862,11 @@ Grid.prototype._recalculateFormulas = function(e) {
|
|
3850
3862
|
Grid.prototype._snapshotFillerDataChanged = function (e) {
|
3851
3863
|
if (!this._dt) return;
|
3852
3864
|
|
3853
|
-
|
3865
|
+
let data = e.data;
|
3854
3866
|
if(e.timeSeries) {
|
3855
3867
|
this._updateTimeSeriesFields(e); // Increase or decrease time series field
|
3856
3868
|
} else {
|
3857
|
-
for (
|
3869
|
+
for (let ric in data) {
|
3858
3870
|
this.setRicData(ric, data[ric]);
|
3859
3871
|
}
|
3860
3872
|
}
|
@@ -3869,7 +3881,7 @@ Grid.prototype._snapshotFillerDataChanged = function (e) {
|
|
3869
3881
|
Grid.prototype._startPolling = function () {
|
3870
3882
|
if(this._pollingEnabled && this._pollingInterval) {
|
3871
3883
|
if(this._lastPollingRequest && !this._pollingTimerId) {
|
3872
|
-
|
3884
|
+
let now = new Date();
|
3873
3885
|
this._lastPollingRequest = now.getTime();
|
3874
3886
|
this._pollingTimerId = setTimeout(this._onPollingInterval, this._pollingInterval);
|
3875
3887
|
}
|
@@ -3891,9 +3903,9 @@ Grid.prototype.activateADCPolling = function (activated) {
|
|
3891
3903
|
if(activated !== false) {
|
3892
3904
|
this._pollingEnabled = true;
|
3893
3905
|
// Make immediate request after re-activation if it has been a long time
|
3894
|
-
|
3906
|
+
let now = new Date();
|
3895
3907
|
if(this._lastPollingRequest) {
|
3896
|
-
|
3908
|
+
let diff = now.getTime() - this._lastPollingRequest;
|
3897
3909
|
if(diff > this._pollingInterval) {
|
3898
3910
|
this.refreshADCData();
|
3899
3911
|
}
|
@@ -3908,7 +3920,7 @@ Grid.prototype.activateADCPolling = function (activated) {
|
|
3908
3920
|
* @return {boolean} Return true, if a request has been made
|
3909
3921
|
*/
|
3910
3922
|
Grid.prototype.refreshADCData = function () {
|
3911
|
-
|
3923
|
+
let dirty = this._snapshot.addFields(this._connector.getAllFields());
|
3912
3924
|
if(dirty) {
|
3913
3925
|
dirty = this._snapshot.addRics(this._connector.getAllRics());
|
3914
3926
|
if(dirty) {
|
@@ -3922,9 +3934,9 @@ Grid.prototype.refreshADCData = function () {
|
|
3922
3934
|
/** @private
|
3923
3935
|
*/
|
3924
3936
|
Grid.prototype._onAutoLayoutUpdate = function() {
|
3925
|
-
|
3937
|
+
let elem = this._topNode;
|
3926
3938
|
|
3927
|
-
|
3939
|
+
let cw = elem.clientWidth;
|
3928
3940
|
if(cw !== this._clientWidth) {
|
3929
3941
|
this._clientWidth = cw;
|
3930
3942
|
this.updateLayout();
|
@@ -3936,7 +3948,7 @@ Grid.prototype._onAutoLayoutUpdate = function() {
|
|
3936
3948
|
* @param {Object=} opt_options { "colNames": Array.<string>, "rowCount": number, "startIndex": number, "getter": function(Object, string):* }
|
3937
3949
|
*/
|
3938
3950
|
Grid.prototype.logDT = function(opt_options) {
|
3939
|
-
|
3951
|
+
let rowDefs = this._getAllRowDefinitions();
|
3940
3952
|
this._logData(rowDefs, opt_options);
|
3941
3953
|
};
|
3942
3954
|
/** @description Log DataView to console. By default, this will log only fields specified in the column definition. To see other column data use "colNames" options
|
@@ -3954,7 +3966,7 @@ Grid.prototype.logDT = function(opt_options) {
|
|
3954
3966
|
grid.logDV({"rowCount": 10}); // Showing 10 records
|
3955
3967
|
*/
|
3956
3968
|
Grid.prototype.logDV = function(opt_options) {
|
3957
|
-
|
3969
|
+
let rowDefs = this.getRowDefinitions();
|
3958
3970
|
this._logData(rowDefs, opt_options);
|
3959
3971
|
};
|
3960
3972
|
/** Log the collection of data to console
|
@@ -3970,7 +3982,7 @@ Grid.prototype._logData = function(rowDefs, options) {
|
|
3970
3982
|
// TODO: Get all required fields and eliminate duplicate fields
|
3971
3983
|
options["colNames"] = this.getColumnFields();
|
3972
3984
|
}
|
3973
|
-
|
3985
|
+
let tbl = DataCache.constructTable(rowDefs.map(toRowData), options);
|
3974
3986
|
|
3975
3987
|
console.table(tbl); // eslint-disable-line
|
3976
3988
|
};
|
@@ -3982,17 +3994,17 @@ Grid.prototype._logData = function(rowDefs, options) {
|
|
3982
3994
|
* @returns {RowDefinition}
|
3983
3995
|
*/
|
3984
3996
|
Grid.prototype.replaceRow = function(rowRef, rowOption) {
|
3985
|
-
|
3986
|
-
|
3997
|
+
let rowId = this._getRowId(rowRef);
|
3998
|
+
let rowDef = this._getRowDefinitionByRef(rowRef);
|
3987
3999
|
if(rowDef.isAutoGenerated()) { // Users cannot replace auto-generated
|
3988
4000
|
return null;
|
3989
4001
|
}
|
3990
|
-
|
4002
|
+
let configObj = rowDef.getConfigObject();
|
3991
4003
|
|
3992
4004
|
if(deepEqual(configObj, rowOption)){
|
3993
4005
|
return null;
|
3994
4006
|
} else {
|
3995
|
-
|
4007
|
+
let insertedRow = this.insertRow(rowOption, rowId);
|
3996
4008
|
this.removeRow(rowId);
|
3997
4009
|
return insertedRow;
|
3998
4010
|
}
|