@refinitiv-ui/efx-grid 6.0.91 → 6.0.92
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.d.ts +1 -1
- package/lib/column-dragging/es6/ColumnDragging.js +144 -34
- package/lib/core/dist/core.js +2410 -2621
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/ColumnStats.js +14 -14
- package/lib/core/es6/data/DataCache.js +118 -118
- package/lib/core/es6/data/DataTable.d.ts +3 -1
- package/lib/core/es6/data/DataTable.js +208 -190
- package/lib/core/es6/data/DataView.d.ts +1 -1
- package/lib/core/es6/data/DataView.js +291 -291
- package/lib/core/es6/data/Segment.js +79 -79
- package/lib/core/es6/data/SegmentCollection.js +81 -81
- package/lib/core/es6/data/WrappedView.js +41 -41
- package/lib/core/es6/grid/Core.js +635 -635
- package/lib/core/es6/grid/ILayoutGrid.js +1 -1
- package/lib/core/es6/grid/LayoutGrid.js +183 -183
- package/lib/core/es6/grid/VirtualizedLayoutGrid.js +91 -91
- package/lib/core/es6/grid/components/Cell.js +29 -29
- package/lib/core/es6/grid/components/CellFloatingPanel.js +11 -11
- package/lib/core/es6/grid/components/CellSpan.js +7 -7
- package/lib/core/es6/grid/components/CellSpans.js +36 -34
- package/lib/core/es6/grid/components/Column.js +40 -40
- package/lib/core/es6/grid/components/ElementWrapper.js +17 -17
- package/lib/core/es6/grid/components/HScrollbar.js +31 -31
- package/lib/core/es6/grid/components/Scrollbar.js +77 -77
- package/lib/core/es6/grid/components/StretchedCells.js +49 -49
- package/lib/core/es6/grid/components/VScrollbar.js +11 -11
- package/lib/core/es6/grid/components/VirtualItems.js +3 -3
- package/lib/core/es6/grid/event/EventDispatcher.js +9 -9
- package/lib/core/es6/grid/event/EventListeners.js +4 -4
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +186 -186
- package/lib/core/es6/grid/util/Conflator.js +4 -4
- package/lib/core/es6/grid/util/Reverter.js +1 -1
- package/lib/core/es6/grid/util/SectionSettings.js +20 -20
- package/lib/core/es6/grid/util/SelectionList.js +23 -23
- package/lib/core/es6/grid/util/TrackLayout.js +74 -74
- package/lib/core/es6/grid/util/Virtualizer.js +15 -15
- package/lib/core/es6/grid/util/util.js +20 -20
- package/lib/core/es6/index.d.ts +0 -2
- package/lib/core/es6/index.js +0 -3
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +193 -70
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.js +46 -30
- package/lib/rt-grid/es6/RowDefinition.d.ts +2 -1
- package/lib/rt-grid/es6/RowDefinition.js +74 -16
- package/lib/tr-grid-cell-selection/es6/CellSelection.js +56 -1
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +3 -1
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +29 -1
- package/lib/tr-grid-util/es6/CellPainter.js +94 -93
- package/lib/tr-grid-util/es6/Conflator.js +4 -4
- package/lib/tr-grid-util/es6/CoralItems.js +6 -6
- package/lib/tr-grid-util/es6/DateTime.js +39 -39
- package/lib/tr-grid-util/es6/Deferred.js +5 -5
- package/lib/tr-grid-util/es6/Delay.js +1 -1
- package/lib/tr-grid-util/es6/Dom.js +26 -26
- package/lib/tr-grid-util/es6/DragUI.js +17 -17
- package/lib/tr-grid-util/es6/ElementObserver.js +12 -12
- package/lib/tr-grid-util/es6/ElementWrapper.js +2 -2
- package/lib/tr-grid-util/es6/ElfDate.js +4 -4
- package/lib/tr-grid-util/es6/ElfUtil.js +37 -37
- package/lib/tr-grid-util/es6/EventDispatcher.js +12 -12
- package/lib/tr-grid-util/es6/ExpanderIcon.js +6 -6
- package/lib/tr-grid-util/es6/ExpressionParser.js +43 -43
- package/lib/tr-grid-util/es6/Ext.js +6 -6
- package/lib/tr-grid-util/es6/FieldFormatter.js +17 -17
- package/lib/tr-grid-util/es6/FilterBuilder.js +57 -57
- package/lib/tr-grid-util/es6/FilterOperators.d.ts +12 -1
- package/lib/tr-grid-util/es6/FilterOperators.js +13 -2
- package/lib/tr-grid-util/es6/GridPlugin.js +86 -86
- package/lib/tr-grid-util/es6/GroupDefinitions.js +90 -90
- package/lib/tr-grid-util/es6/Icon.js +4 -4
- package/lib/tr-grid-util/es6/MouseDownTrait.js +6 -6
- package/lib/tr-grid-util/es6/MultiTableManager.js +68 -68
- package/lib/tr-grid-util/es6/NumberFormatter.js +22 -22
- package/lib/tr-grid-util/es6/PercentBar.js +17 -17
- package/lib/tr-grid-util/es6/Perf.js +5 -5
- package/lib/tr-grid-util/es6/Popup.js +42 -42
- package/lib/tr-grid-util/es6/RangeBar.js +5 -5
- package/lib/tr-grid-util/es6/RequestQueue.js +5 -5
- package/lib/tr-grid-util/es6/RowPainter.js +23 -23
- package/lib/tr-grid-util/es6/SubTable.js +94 -94
- package/lib/tr-grid-util/es6/Table.js +51 -51
- package/lib/tr-grid-util/es6/TextHighlighter.js +49 -49
- package/lib/tr-grid-util/es6/TickCodes.js +2 -2
- package/lib/tr-grid-util/es6/Timer.js +2 -2
- package/lib/tr-grid-util/es6/TouchProxy.js +7 -7
- package/lib/tr-grid-util/es6/Util.js +50 -50
- package/lib/tr-grid-util/es6/formula/ADCService.js +2 -2
- package/lib/tr-grid-util/es6/formula/ADCSubscription.js +19 -19
- package/lib/tr-grid-util/es6/formula/AdFinService.js +2 -2
- package/lib/tr-grid-util/es6/formula/AdFinSubscription.js +19 -19
- package/lib/tr-grid-util/es6/formula/Engine.js +56 -56
- package/lib/tr-grid-util/es6/formula/Formula.js +62 -62
- package/lib/tr-grid-util/es6/formula/IntervalSubscription.js +3 -3
- package/lib/tr-grid-util/es6/formula/Realtime.js +15 -15
- package/lib/tr-grid-util/es6/formula/RealtimeService.js +15 -15
- package/lib/tr-grid-util/es6/formula/TSIService.js +2 -2
- package/lib/tr-grid-util/es6/formula/TSISubscription.js +104 -104
- package/lib/tr-grid-util/es6/formula/VariableToken.js +20 -20
- package/lib/tr-grid-util/es6/formula/functions/AdFin.js +10 -10
- package/lib/tr-grid-util/es6/formula/functions/Excel.js +1 -1
- package/lib/tr-grid-util/es6/formula/functions/Info.js +2 -2
- package/lib/tr-grid-util/es6/formula/functions/Internal.js +5 -5
- package/lib/tr-grid-util/es6/formula/functions/Logic.js +5 -5
- package/lib/tr-grid-util/es6/formula/functions/Math.js +46 -46
- package/lib/tr-grid-util/es6/formula/functions/Statistics.js +27 -27
- package/lib/tr-grid-util/es6/formula/functions/Text.js +19 -19
- package/lib/tr-grid-util/es6/index.js +1 -1
- package/lib/tr-grid-util/es6/jet/Adc.js +36 -36
- package/lib/tr-grid-util/es6/jet/CollectionDict.js +11 -11
- package/lib/tr-grid-util/es6/jet/DataGenerator.js +95 -95
- package/lib/tr-grid-util/es6/jet/DataSet.js +1 -1
- package/lib/tr-grid-util/es6/jet/MockArchive.js +5 -5
- package/lib/tr-grid-util/es6/jet/MockJET.js +1 -1
- package/lib/tr-grid-util/es6/jet/MockQuotes.js +13 -13
- package/lib/tr-grid-util/es6/jet/MockQuotes2.js +100 -100
- package/lib/tr-grid-util/es6/jet/MockRTK.js +4 -4
- package/lib/tr-grid-util/es6/jet/MockUtil.js +2 -2
- package/lib/tr-grid-util/es6/jet/index.js +1 -1
- package/lib/tr-grid-util/es6/jet/mockDataAPI.js +15 -15
- package/lib/tr-grid-util/es6/locale/translation-de.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-en.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-ja.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-zh-hant.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-zh.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation.js +1 -1
- package/lib/types/es6/ColumnDragging.d.ts +1 -1
- package/lib/types/es6/ColumnGrouping.d.ts +3 -1
- package/lib/types/es6/Core/data/DataTable.d.ts +4 -0
- package/lib/types/es6/Core/data/DataView.d.ts +2 -0
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +2 -0
- package/lib/types/es6/Core/index.d.ts +0 -2
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +2 -1
- package/lib/versions.json +4 -4
- package/package.json +1 -1
- package/lib/core/es6/grid/util/ElementFrameWork.d.ts +0 -18
- package/lib/core/es6/grid/util/ElementFrameWork.js +0 -227
- package/lib/core/es6/grid/util/HttpRequest.d.ts +0 -53
- package/lib/core/es6/grid/util/HttpRequest.js +0 -371
- package/lib/core/es6/grid/util/PercentBar.d.ts +0 -43
- package/lib/core/es6/grid/util/PercentBar.js +0 -390
- package/lib/core/es6/grid/util/PercentBarRenderer.d.ts +0 -41
- package/lib/core/es6/grid/util/PercentBarRenderer.js +0 -316
- package/lib/core/es6/grid/util/RangeBar.d.ts +0 -25
- package/lib/core/es6/grid/util/RangeBar.js +0 -255
- package/lib/types/es6/Core/grid/util/ElementFrameWork.d.ts +0 -18
- package/lib/types/es6/Core/grid/util/HttpRequest.d.ts +0 -53
- package/lib/types/es6/Core/grid/util/PercentBar.d.ts +0 -43
- package/lib/types/es6/Core/grid/util/PercentBarRenderer.d.ts +0 -41
- package/lib/types/es6/Core/grid/util/RangeBar.d.ts +0 -25
|
@@ -19,7 +19,7 @@ import SegmentCollection from "./SegmentCollection.js";
|
|
|
19
19
|
/** @constructor
|
|
20
20
|
* @extends {DataCache}
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
let DataTable = function() {
|
|
23
23
|
DataTable.base(this, 'constructor');
|
|
24
24
|
|
|
25
25
|
this._removeRows = this._removeRows.bind(this);
|
|
@@ -104,7 +104,7 @@ DataTable.prototype._classifyingTimer = 0;
|
|
|
104
104
|
* @property {number=} order 1 indicates ascending order, and -1 indicates descending order
|
|
105
105
|
* @property {*=} contextObject Any given user context
|
|
106
106
|
* @example
|
|
107
|
-
*
|
|
107
|
+
* let customComparer = function(a, b, order) {
|
|
108
108
|
* if(a + 10 < b) { return -order; }
|
|
109
109
|
* if(b + 10 < a) { return order; }
|
|
110
110
|
* return 0; // a and b are less than 10 difference apart
|
|
@@ -137,8 +137,8 @@ DataTable.prototype.dispose = function() {
|
|
|
137
137
|
* @override
|
|
138
138
|
*/
|
|
139
139
|
DataTable.prototype.getColumnData = function(cid) {
|
|
140
|
-
|
|
141
|
-
for(
|
|
140
|
+
let rows = new Array(this._rids.length);
|
|
141
|
+
for(let i = this._rids.length; --i >= 0;) {
|
|
142
142
|
rows[i] = this._rows[this._rids[i]][cid];
|
|
143
143
|
}
|
|
144
144
|
return rows;
|
|
@@ -195,7 +195,7 @@ DataTable.prototype.getRowDataAt = function(rowIndex) {
|
|
|
195
195
|
* @return {Object.<string, *>}
|
|
196
196
|
*/
|
|
197
197
|
DataTable.prototype.getPreviousData = function(rid, cid) {
|
|
198
|
-
|
|
198
|
+
let row = this._prevData[rid] || null;
|
|
199
199
|
if(row) {
|
|
200
200
|
return row[cid];
|
|
201
201
|
}
|
|
@@ -214,19 +214,45 @@ DataTable.prototype.setData = function(rid, cid, value) { // Data changed event
|
|
|
214
214
|
if(!this._needFiring()) {
|
|
215
215
|
return this._setData(rid, cid, value);
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
let values = {};
|
|
218
218
|
values[cid] = value;
|
|
219
219
|
return this.setRowData(rid, values);
|
|
220
220
|
};
|
|
221
|
+
/** @private
|
|
222
|
+
* @param {string} rid Row Id
|
|
223
|
+
* @returns {boolean}
|
|
224
|
+
*/
|
|
225
|
+
DataTable.prototype._removeRidFromSegments = function(rid) {
|
|
226
|
+
if(this._segments) {
|
|
227
|
+
let segment = this._segments.getSegment(rid);
|
|
228
|
+
if(segment) {
|
|
229
|
+
if(this._segments.removeSegment(rid)) {
|
|
230
|
+
// TODO: Handle sub segment removal
|
|
231
|
+
if(!this._segments.getSegmentCount()) {
|
|
232
|
+
this._segments.dispose();
|
|
233
|
+
this._segments = null;
|
|
234
|
+
}
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
let segmentParentId = this._segments.getParentRowId(rid);
|
|
239
|
+
if(segmentParentId) {
|
|
240
|
+
this._segments.removeSegmentChild(segmentParentId, rid);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
245
|
+
};
|
|
221
246
|
/** Set data in row manner
|
|
222
247
|
* @override
|
|
248
|
+
* @public
|
|
223
249
|
* @param {string} rid Row Id
|
|
224
250
|
* @param {Object.<string, *>=} values Object where the key is column Id and value is the data to be set
|
|
225
251
|
* @param {Object=} eventArg Additional arguments to be attached to the event fired
|
|
226
252
|
* @return {boolean} Return true if there is any change, and false otherwise
|
|
227
253
|
* @fires DataTable#dataChanged
|
|
228
254
|
* @example
|
|
229
|
-
*
|
|
255
|
+
* let dt = new DataTable();
|
|
230
256
|
* dt.setRowData("row 1", {"column 1": "a", "column 2": 1, "column 3": null});
|
|
231
257
|
* dt.log(); // See console for the results
|
|
232
258
|
*/
|
|
@@ -235,10 +261,10 @@ DataTable.prototype.setRowData = function(rid, values, eventArg) { // Data chang
|
|
|
235
261
|
return false;
|
|
236
262
|
}
|
|
237
263
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
264
|
+
let row = this.getRowData(rid);
|
|
265
|
+
let dirty = false;
|
|
266
|
+
let type = "updated";
|
|
267
|
+
let segmentChanged = false;
|
|
242
268
|
|
|
243
269
|
if(values) {
|
|
244
270
|
if(!row) {
|
|
@@ -247,8 +273,8 @@ DataTable.prototype.setRowData = function(rid, values, eventArg) { // Data chang
|
|
|
247
273
|
this._rows[rid] = row; // WARNING: Dangerous use of external reference. User may modify data without using DataTable's API
|
|
248
274
|
this._prevData[rid] = {};
|
|
249
275
|
if(eventArg) {
|
|
250
|
-
|
|
251
|
-
|
|
276
|
+
let nextRid = /** @type{string} */(eventArg["nextRid"]); // Used for insertion only
|
|
277
|
+
let rowIndex = (nextRid) ? this.getRowIndex(nextRid) : -1;
|
|
252
278
|
if(rowIndex < 0) {
|
|
253
279
|
rowIndex = /** @type{number} */(eventArg["fallback"]);
|
|
254
280
|
}
|
|
@@ -262,8 +288,8 @@ DataTable.prototype.setRowData = function(rid, values, eventArg) { // Data chang
|
|
|
262
288
|
this._rids.push(rid);
|
|
263
289
|
}
|
|
264
290
|
} else {
|
|
265
|
-
|
|
266
|
-
for (
|
|
291
|
+
let prevData = this._prevData[rid];
|
|
292
|
+
for (let cid in values) {
|
|
267
293
|
prevData[cid] = row[cid];
|
|
268
294
|
row[cid] = values[cid];
|
|
269
295
|
}
|
|
@@ -276,18 +302,7 @@ DataTable.prototype.setRowData = function(rid, values, eventArg) { // Data chang
|
|
|
276
302
|
// delete this._prevData[rid];
|
|
277
303
|
this._prevData[rid] = this._rows[rid]; // Move reference from the removed row to history
|
|
278
304
|
delete this._rows[rid];
|
|
279
|
-
|
|
280
|
-
var segment = this._segments.getSegment(rid);
|
|
281
|
-
if(segment) {
|
|
282
|
-
if(this._segments.removeSegment(rid)) {
|
|
283
|
-
// TODO: Handle sub segment removal
|
|
284
|
-
segmentChanged = true;
|
|
285
|
-
if(!this._segments.getSegmentCount()) {
|
|
286
|
-
this._segments = null;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
305
|
+
segmentChanged = this._removeRidFromSegments(rid);
|
|
291
306
|
DataTable._removeArrayItem(this._rids, rid);
|
|
292
307
|
dirty = true;
|
|
293
308
|
}
|
|
@@ -297,7 +312,7 @@ DataTable.prototype.setRowData = function(rid, values, eventArg) { // Data chang
|
|
|
297
312
|
if(this._autoFillSegments()) {
|
|
298
313
|
this.dispatchGlobalChange();
|
|
299
314
|
} else {
|
|
300
|
-
|
|
315
|
+
let e = eventArg || {};
|
|
301
316
|
e["rid"] = rid;
|
|
302
317
|
e["changes"] = values; // WARNING: External user data is passed along
|
|
303
318
|
e["rowData"] = row;
|
|
@@ -317,19 +332,19 @@ DataTable.prototype.setRowData = function(rid, values, eventArg) { // Data chang
|
|
|
317
332
|
* @param {Array.<*>} valueList
|
|
318
333
|
* @param {Array.<string>=} opt_ridList Specify row id to be set corresponding to the data item
|
|
319
334
|
* @example
|
|
320
|
-
*
|
|
335
|
+
* let dt = new DataTable();
|
|
321
336
|
* dt.setColumnData("column 1", ["1st row data", "2nd row data", "3rd row data"]);
|
|
322
337
|
* dt.log(); // See console for the results
|
|
323
338
|
*/
|
|
324
339
|
DataTable.prototype.setColumnData = function(cid, valueList, opt_ridList) { // Data changed event may be dispatched
|
|
325
|
-
|
|
340
|
+
let rLen = (valueList) ? valueList.length : 0;
|
|
326
341
|
if(rLen < 0) { return; }
|
|
327
342
|
|
|
328
|
-
|
|
343
|
+
let prevFrozen = this._frozen;
|
|
329
344
|
this.freeze();
|
|
330
|
-
|
|
345
|
+
let rids = this._generateRids(rLen, opt_ridList);
|
|
331
346
|
|
|
332
|
-
for(
|
|
347
|
+
for(let r = 0; r < rLen; ++r) {
|
|
333
348
|
this._setData(rids[r], cid, valueList[r]);
|
|
334
349
|
}
|
|
335
350
|
|
|
@@ -344,12 +359,12 @@ Row id with null value will cause a removal of the row with the same id.
|
|
|
344
359
|
* @see {@link DataTable#addRows}
|
|
345
360
|
* @see {@link DataTable#setDataFrom2DArray}
|
|
346
361
|
* @example
|
|
347
|
-
*
|
|
362
|
+
* let data = {
|
|
348
363
|
* "rowId 1": {"column 1": "a", "column 2": 1, "column 3": 2},
|
|
349
364
|
* "rowId 2": {"column 1": "b", "column 2": 3, "column 3": 4},
|
|
350
365
|
* "rowId 4": {"column 1": "d", "group_criteria": 1} // Rows don't need to be in uniform structure
|
|
351
366
|
* };
|
|
352
|
-
*
|
|
367
|
+
* let dt = new DataTable();
|
|
353
368
|
* dt.setDataFromObjectMap(data);
|
|
354
369
|
* dt.log(); // See console for the results
|
|
355
370
|
* dt.setDataFromObjectMap({"rowId 1": null}); // Remove the row with "rowId 1"
|
|
@@ -364,10 +379,10 @@ DataTable.prototype.setDataFromObjectMap = function(obj) {
|
|
|
364
379
|
return;
|
|
365
380
|
}
|
|
366
381
|
|
|
367
|
-
|
|
382
|
+
let prevFrozen = this._frozen;
|
|
368
383
|
this.freeze();
|
|
369
384
|
|
|
370
|
-
for(
|
|
385
|
+
for(let rid in obj) {
|
|
371
386
|
this.setRowData(rid, obj[rid]);
|
|
372
387
|
}
|
|
373
388
|
|
|
@@ -381,28 +396,28 @@ DataTable.prototype.setDataFromObjectMap = function(obj) {
|
|
|
381
396
|
* @see {@link DataTable#addRows}
|
|
382
397
|
* @see {@link DataTable#setDataFromObjectMap}
|
|
383
398
|
* @example
|
|
384
|
-
*
|
|
399
|
+
* let data = [
|
|
385
400
|
* ["a", 1, 2],
|
|
386
401
|
* ["b", 3, 4],
|
|
387
402
|
* ["c", 5, 6]
|
|
388
403
|
* ];
|
|
389
|
-
*
|
|
404
|
+
* let dt = new DataTable();
|
|
390
405
|
* dt.setDataFrom2DArray(data, ["column 1", "column 2", "column 3"]);
|
|
391
406
|
* dt.log(); // See console for the results
|
|
392
407
|
*/
|
|
393
408
|
DataTable.prototype.setDataFrom2DArray = function(ary, opt_cidList, opt_ridList) {
|
|
394
|
-
|
|
409
|
+
let rLen = (ary) ? ary.length : 0;
|
|
395
410
|
if(rLen < 0) { return; }
|
|
396
411
|
|
|
397
|
-
|
|
412
|
+
let prevFrozen = this._frozen;
|
|
398
413
|
this.freeze();
|
|
399
414
|
|
|
400
|
-
|
|
401
|
-
|
|
415
|
+
let c = 0;
|
|
416
|
+
let rids = this._generateRids(rLen, opt_ridList);
|
|
402
417
|
|
|
403
|
-
for(
|
|
404
|
-
|
|
405
|
-
|
|
418
|
+
for(let r = 0; r < rLen; ++r) {
|
|
419
|
+
let row = ary[r];
|
|
420
|
+
let rid = rids[r];
|
|
406
421
|
if(opt_cidList) {
|
|
407
422
|
for(c = row.length; --c >= 0;) {
|
|
408
423
|
this._setData(rid, opt_cidList[c], row[c]);
|
|
@@ -426,7 +441,7 @@ DataTable.prototype.setDataFrom2DArray = function(ary, opt_cidList, opt_ridList)
|
|
|
426
441
|
* @fires DataTable#dataChanged
|
|
427
442
|
*/
|
|
428
443
|
DataTable.prototype.setDataAt = function(rowIndex, cid, value) { // Data changed event may be dispatched
|
|
429
|
-
|
|
444
|
+
let rid = this.getRowId(rowIndex);
|
|
430
445
|
return (rid) ? this.setData(rid, cid, value) : false;
|
|
431
446
|
};
|
|
432
447
|
/** @public
|
|
@@ -437,7 +452,7 @@ DataTable.prototype.setDataAt = function(rowIndex, cid, value) { // Data changed
|
|
|
437
452
|
* @fires DataTable#dataChanged
|
|
438
453
|
*/
|
|
439
454
|
DataTable.prototype.setRowDataAt = function(rowIndex, values, opt_eventArg) { // Data changed event may be dispatched
|
|
440
|
-
|
|
455
|
+
let rid = this.getRowId(rowIndex);
|
|
441
456
|
return (rid) ? this.setRowData(rid, values, opt_eventArg) : false;
|
|
442
457
|
};
|
|
443
458
|
/** Add new row of data to the end of the Data Table
|
|
@@ -447,7 +462,7 @@ DataTable.prototype.setRowDataAt = function(rowIndex, values, opt_eventArg) { //
|
|
|
447
462
|
* @return {string} Return Row id that has been inserted or changed
|
|
448
463
|
* @fires DataTable#dataChanged
|
|
449
464
|
* @example
|
|
450
|
-
*
|
|
465
|
+
* let dt = new DataTable();
|
|
451
466
|
* dt.addRow({"column 1": "a", "column 2": 1, "column 3": null});
|
|
452
467
|
* dt.addRow({"column 1": "b", "column 2": 5, "column 3": {"someKey": 10}});
|
|
453
468
|
* dt.log(); // See console for the results
|
|
@@ -467,7 +482,7 @@ DataTable.prototype.addRow = function(values, rid) {
|
|
|
467
482
|
* @see {@link DataTable#setDataFrom2DArray}
|
|
468
483
|
* @see {@link DataTable#setDataFromObjectMap}
|
|
469
484
|
* @example
|
|
470
|
-
*
|
|
485
|
+
* let dt = new DataTable();
|
|
471
486
|
* dt.addRows([
|
|
472
487
|
* {"field1": "a", "field2": 1, "field3": null},
|
|
473
488
|
* {"field1": "b", "field2": 5, "field3": {"someKey": 10}},
|
|
@@ -480,7 +495,7 @@ DataTable.prototype.addRows = function(rows, rids) {
|
|
|
480
495
|
if(!Array.isArray(rows)) {
|
|
481
496
|
return;
|
|
482
497
|
}
|
|
483
|
-
|
|
498
|
+
let len = rows.length;
|
|
484
499
|
if(!len) {
|
|
485
500
|
return;
|
|
486
501
|
} else if(len === 1) {
|
|
@@ -490,9 +505,9 @@ DataTable.prototype.addRows = function(rows, rids) {
|
|
|
490
505
|
if(!rids) {
|
|
491
506
|
rids = [];
|
|
492
507
|
}
|
|
493
|
-
|
|
508
|
+
let prevFrozen = this._frozen;
|
|
494
509
|
this.freeze();
|
|
495
|
-
for(
|
|
510
|
+
for(let i = 0; i < len; ++i) {
|
|
496
511
|
this.addRow(rows[i], rids[i]);
|
|
497
512
|
}
|
|
498
513
|
this.freeze(prevFrozen);
|
|
@@ -519,7 +534,7 @@ DataTable.prototype.unshiftRow = function(opt_values, opt_rid) {
|
|
|
519
534
|
* @see {@link DataTable#removeRow}
|
|
520
535
|
*/
|
|
521
536
|
DataTable.prototype.insertRow = function(rowRef, values, rid) {
|
|
522
|
-
|
|
537
|
+
let arg = null;
|
|
523
538
|
if(typeof rowRef === "number") {
|
|
524
539
|
arg = {};
|
|
525
540
|
arg["nextRid"] = this._rids[rowRef];
|
|
@@ -543,7 +558,7 @@ DataTable.prototype.insertRow = function(rowRef, values, rid) {
|
|
|
543
558
|
* @fires DataTable#dataChanged
|
|
544
559
|
*/
|
|
545
560
|
DataTable.prototype.insertAfter = function(rowRef, opt_values, opt_rid) {
|
|
546
|
-
|
|
561
|
+
let rowIndex = (typeof rowRef === "string") ? this.getRowIndex(rowRef) : /** @type{number}*/ (rowRef);
|
|
547
562
|
|
|
548
563
|
if(!(rowIndex >= 0) || rowIndex >= this._rids.length - 1) {
|
|
549
564
|
return this.addRow(opt_values, opt_rid);
|
|
@@ -567,8 +582,9 @@ DataTable.prototype.removeRow = function(rowRef) { // Data changed event may be
|
|
|
567
582
|
* @see {@link DataTable#removeAllRows}
|
|
568
583
|
*/
|
|
569
584
|
DataTable.prototype.removeRows = function(refs) {
|
|
585
|
+
let rid;
|
|
570
586
|
if(refs.length === 1) {
|
|
571
|
-
|
|
587
|
+
rid = refs[0];
|
|
572
588
|
if (typeof rid === "number") {
|
|
573
589
|
this.removeRow(rid);
|
|
574
590
|
} else {
|
|
@@ -577,8 +593,8 @@ DataTable.prototype.removeRows = function(refs) {
|
|
|
577
593
|
return;
|
|
578
594
|
}
|
|
579
595
|
|
|
580
|
-
|
|
581
|
-
|
|
596
|
+
let i;
|
|
597
|
+
let dirty = false;
|
|
582
598
|
this._removedRows = {};
|
|
583
599
|
for (i = refs.length; --i >= 0;) {
|
|
584
600
|
rid = refs[i];
|
|
@@ -586,12 +602,12 @@ DataTable.prototype.removeRows = function(refs) {
|
|
|
586
602
|
rid = this.getRowId(rid);
|
|
587
603
|
}
|
|
588
604
|
|
|
589
|
-
|
|
605
|
+
let row = this.getRowData(rid);
|
|
590
606
|
if(row) {
|
|
591
607
|
this._prevData[rid] = this._rows[rid];
|
|
592
608
|
this._removedRows[rid] = 1;
|
|
593
609
|
delete this._rows[rid];
|
|
594
|
-
|
|
610
|
+
this._removeRidFromSegments(rid);
|
|
595
611
|
dirty = true;
|
|
596
612
|
}
|
|
597
613
|
}
|
|
@@ -617,7 +633,7 @@ DataTable.prototype._removeRows = function(rid) {
|
|
|
617
633
|
* @return {boolean}
|
|
618
634
|
*/
|
|
619
635
|
DataTable._removeArrayItem = function(ary, item) {
|
|
620
|
-
|
|
636
|
+
let at = ary.indexOf(item);
|
|
621
637
|
if(at >= 0) {
|
|
622
638
|
if(at >= ary.length) {
|
|
623
639
|
ary.pop(); // Array.pop is 100 times faster than Array.splice
|
|
@@ -634,9 +650,10 @@ DataTable._removeArrayItem = function(ary, item) {
|
|
|
634
650
|
DataTable.prototype.clearAllData = function(suppressEvent) {
|
|
635
651
|
DataTable.base(this, "clearAllData", true);
|
|
636
652
|
this._prevData = {};
|
|
637
|
-
|
|
653
|
+
|
|
638
654
|
if(this._segments) {
|
|
639
|
-
this._segments.
|
|
655
|
+
this._segments.dispose();
|
|
656
|
+
this._segments = null;
|
|
640
657
|
}
|
|
641
658
|
|
|
642
659
|
if(this._rids.length) {
|
|
@@ -666,18 +683,18 @@ DataTable._ascendingOrder = function(a, b) { return a - b; };
|
|
|
666
683
|
* @return {Array.<string>|string} Return row id(s). Return null if nothing has changed
|
|
667
684
|
*/
|
|
668
685
|
DataTable.prototype.moveRow = function(fromIndex, toIndex, suppressEvent) {
|
|
669
|
-
|
|
670
|
-
|
|
686
|
+
let output = null;
|
|
687
|
+
let rid = "";
|
|
671
688
|
if(!(toIndex >= 0 && toIndex < this._rids.length)) {
|
|
672
689
|
toIndex = this._rids.length;
|
|
673
690
|
}
|
|
674
691
|
|
|
675
692
|
if (Array.isArray(fromIndex)) {
|
|
676
|
-
|
|
693
|
+
let fromIndices = fromIndex;
|
|
677
694
|
fromIndices.sort(DataTable._ascendingOrder);
|
|
678
|
-
|
|
679
|
-
for (
|
|
680
|
-
|
|
695
|
+
let movedRids = [];
|
|
696
|
+
for (let i = fromIndices.length; --i >= 0;) {
|
|
697
|
+
let idx = fromIndices[i];
|
|
681
698
|
rid = this._rids[idx];
|
|
682
699
|
if(rid) {
|
|
683
700
|
movedRids.unshift(rid);
|
|
@@ -725,17 +742,17 @@ DataTable.prototype.moveRow = function(fromIndex, toIndex, suppressEvent) {
|
|
|
725
742
|
* @return {Array.<string>|string} rid
|
|
726
743
|
*/
|
|
727
744
|
DataTable.prototype._moveRow = function(fromRids, toRid, suppressEvent) {
|
|
728
|
-
|
|
745
|
+
let len = fromRids.length;
|
|
729
746
|
if(!len) {
|
|
730
747
|
return null;
|
|
731
748
|
}
|
|
732
749
|
|
|
733
|
-
|
|
734
|
-
for(
|
|
750
|
+
let fromIndices = new Array(len);
|
|
751
|
+
for(let i = 0; i < len; ++i) {
|
|
735
752
|
fromIndices[i] = this.getRowIndex(fromRids[i]);
|
|
736
753
|
}
|
|
737
754
|
|
|
738
|
-
|
|
755
|
+
let toIndex = (toRid) ? this.getRowIndex(toRid) : this._rids.length;
|
|
739
756
|
if(len > 1) {
|
|
740
757
|
return this.moveRow(fromIndices, toIndex, suppressEvent);
|
|
741
758
|
}
|
|
@@ -762,8 +779,8 @@ DataTable.prototype.moveRows = function(startIndex, toIndex, opt_count, suppress
|
|
|
762
779
|
if(toIndex < 0) { toIndex = this._rids.length; }
|
|
763
780
|
if(!opt_count) { opt_count = 1; }
|
|
764
781
|
|
|
765
|
-
|
|
766
|
-
|
|
782
|
+
let endIndex = startIndex + opt_count - 1;
|
|
783
|
+
let targetIndex = toIndex;
|
|
767
784
|
if (toIndex >= startIndex) {
|
|
768
785
|
if (toIndex <= endIndex) {
|
|
769
786
|
targetIndex = startIndex;
|
|
@@ -777,8 +794,8 @@ DataTable.prototype.moveRows = function(startIndex, toIndex, opt_count, suppress
|
|
|
777
794
|
targetIndex = this._rids.length;
|
|
778
795
|
}
|
|
779
796
|
|
|
780
|
-
|
|
781
|
-
|
|
797
|
+
let rows = this._rids.splice(startIndex, opt_count);
|
|
798
|
+
let args = [targetIndex, 0].concat(rows);
|
|
782
799
|
Array.prototype.splice.apply(this._rids, args);
|
|
783
800
|
|
|
784
801
|
if(this._segments) {
|
|
@@ -797,11 +814,11 @@ DataTable.prototype.moveRows = function(startIndex, toIndex, opt_count, suppress
|
|
|
797
814
|
* @param {number} toIndex
|
|
798
815
|
*/
|
|
799
816
|
DataTable.prototype.swapRow = function(fromIndex, toIndex) { // No event is fired. No effect on other views
|
|
800
|
-
|
|
817
|
+
let len = this._rids.length;
|
|
801
818
|
if(fromIndex < 0 || fromIndex >= len) { return; }
|
|
802
819
|
if(toIndex < 0 || toIndex >= len) { return; }
|
|
803
820
|
|
|
804
|
-
|
|
821
|
+
let rid = this._rids[fromIndex];
|
|
805
822
|
this._rids[fromIndex] = this._rids[toIndex];
|
|
806
823
|
this._rids[toIndex] = rid;
|
|
807
824
|
};
|
|
@@ -815,11 +832,11 @@ DataTable.prototype.clearRowData = DataTable.prototype.removeRow;
|
|
|
815
832
|
* @override
|
|
816
833
|
*/
|
|
817
834
|
DataTable.prototype.clearColumnData = function(colId, suppressEvent) {
|
|
818
|
-
|
|
819
|
-
for(
|
|
820
|
-
|
|
835
|
+
let cids = (typeof colId === "string") ? [/** @type {string} */(colId)] : /** @type {Array.<string>} */(colId);
|
|
836
|
+
for(let i = cids.length; --i >= 0;) {
|
|
837
|
+
let cid = cids[i];
|
|
821
838
|
if(cid) {
|
|
822
|
-
for(
|
|
839
|
+
for(let rid in this._rows) {
|
|
823
840
|
delete this._rows[rid][cid];
|
|
824
841
|
delete this._prevData[rid][cid];
|
|
825
842
|
}
|
|
@@ -858,7 +875,7 @@ DataTable.prototype.getSortingLogics = function() {
|
|
|
858
875
|
* @fires DataTable#dataChanged
|
|
859
876
|
*/
|
|
860
877
|
DataTable.prototype.sortOnce = function(cid, sortOrders, customComparer, contextObj) {
|
|
861
|
-
|
|
878
|
+
let sortingDefs = DataTable._buildSortContext(
|
|
862
879
|
[],
|
|
863
880
|
cid,
|
|
864
881
|
sortOrders,
|
|
@@ -878,7 +895,7 @@ DataTable.prototype.sortOnce = function(cid, sortOrders, customComparer, context
|
|
|
878
895
|
* customLogic = function(a, b, sortOrder) {
|
|
879
896
|
* return (a - b) * sortOrder; // for numeric comparison
|
|
880
897
|
* };
|
|
881
|
-
*
|
|
898
|
+
* let dt = new DataTable();
|
|
882
899
|
* dt.setSortingLogic(customLogic);
|
|
883
900
|
* dt.sortOnce("Column id", "ascending");
|
|
884
901
|
*/
|
|
@@ -902,7 +919,7 @@ DataTable.prototype.setColumnSortingLogic = function(cid, func) {
|
|
|
902
919
|
*/
|
|
903
920
|
DataTable.prototype.getColumnSortingLogic = function(cid) {
|
|
904
921
|
if(cid) {
|
|
905
|
-
|
|
922
|
+
let logic = this._compMap[cid];
|
|
906
923
|
if(logic) {
|
|
907
924
|
return logic;
|
|
908
925
|
}
|
|
@@ -917,15 +934,15 @@ DataTable.prototype.getColumnSortingLogic = function(cid) {
|
|
|
917
934
|
* @return {boolean} Previous freeze state before the execution
|
|
918
935
|
* @fires DataTable#dataChanged
|
|
919
936
|
* @example
|
|
920
|
-
*
|
|
921
|
-
* for(
|
|
937
|
+
* let prevState = dt.freeze();
|
|
938
|
+
* for(let i = 0; i < 100; ++i) {
|
|
922
939
|
* dt.insertRow(); // no event is fired
|
|
923
940
|
* }
|
|
924
941
|
* dt.freeze(prevState); // Restore previous freeze states
|
|
925
942
|
*/
|
|
926
943
|
DataTable.prototype.freeze = function(bool) {
|
|
927
944
|
bool = bool !== false;
|
|
928
|
-
|
|
945
|
+
let prevState = this._frozen;
|
|
929
946
|
if(prevState !== bool) {
|
|
930
947
|
this._frozen = bool;
|
|
931
948
|
this._autoFillSegments();
|
|
@@ -955,8 +972,8 @@ DataTable.prototype.isFrozen = function() {
|
|
|
955
972
|
* @return {boolean} Return true if there is any change
|
|
956
973
|
*/
|
|
957
974
|
DataTable.prototype.setSegmentSeparator = function(rid, enabled) {
|
|
958
|
-
|
|
959
|
-
|
|
975
|
+
let change = false;
|
|
976
|
+
let memberCount = 0;
|
|
960
977
|
if(rid && typeof rid === "string") {
|
|
961
978
|
if(enabled !== false) {
|
|
962
979
|
if(!this._segments) {
|
|
@@ -964,7 +981,7 @@ DataTable.prototype.setSegmentSeparator = function(rid, enabled) {
|
|
|
964
981
|
this._segments.addEventListener("subSegmentChanged", this._onSubSegmentChanged);
|
|
965
982
|
}
|
|
966
983
|
if(this._autoSegmentFilling) {
|
|
967
|
-
|
|
984
|
+
let parentId = this._segments.getParentRowId(rid);
|
|
968
985
|
if(parentId) {
|
|
969
986
|
this._segments.removeSegmentChild(parentId, rid);
|
|
970
987
|
}
|
|
@@ -974,7 +991,7 @@ DataTable.prototype.setSegmentSeparator = function(rid, enabled) {
|
|
|
974
991
|
change = true;
|
|
975
992
|
}
|
|
976
993
|
} else if(this._segments) {
|
|
977
|
-
|
|
994
|
+
let segment = this._segments.getSegment(rid);
|
|
978
995
|
if(segment) {
|
|
979
996
|
memberCount = segment.getChildCount();
|
|
980
997
|
if(this._segments.removeSegment(rid)) {
|
|
@@ -990,7 +1007,7 @@ DataTable.prototype.setSegmentSeparator = function(rid, enabled) {
|
|
|
990
1007
|
if(this._autoFillSegments() || memberCount) {
|
|
991
1008
|
this.dispatchGlobalChange();
|
|
992
1009
|
} else {
|
|
993
|
-
|
|
1010
|
+
let rowData = this._rows[rid] || null;
|
|
994
1011
|
if(rowData) {
|
|
995
1012
|
this._dispatchDataChange({
|
|
996
1013
|
"rid": rid,
|
|
@@ -1010,6 +1027,7 @@ DataTable.prototype.setSegmentSeparator = function(rid, enabled) {
|
|
|
1010
1027
|
*/
|
|
1011
1028
|
DataTable.prototype.unsetAllSegmentSeparators = function() {
|
|
1012
1029
|
if(this._segments) {
|
|
1030
|
+
this._segments.dispose();
|
|
1013
1031
|
this._segments = null;
|
|
1014
1032
|
this.dispatchGlobalChange();
|
|
1015
1033
|
return true;
|
|
@@ -1048,7 +1066,7 @@ DataTable.prototype.getSegment = function(rid) {
|
|
|
1048
1066
|
/**
|
|
1049
1067
|
* @public
|
|
1050
1068
|
* @param {string} rid Row id of a segment child
|
|
1051
|
-
* @return {
|
|
1069
|
+
* @return {Segment} Returns null if a segment cannot be found
|
|
1052
1070
|
*/
|
|
1053
1071
|
DataTable.prototype.getSegmentParent = function(rid) {
|
|
1054
1072
|
if(this._segments) {
|
|
@@ -1062,7 +1080,7 @@ DataTable.prototype.getSegmentParent = function(rid) {
|
|
|
1062
1080
|
* @return {number} Return 0 if the given rid is not a segment
|
|
1063
1081
|
*/
|
|
1064
1082
|
DataTable.prototype.getSegmentLevel = function(rid) {
|
|
1065
|
-
|
|
1083
|
+
let segment = this.getSegment(rid);
|
|
1066
1084
|
if(segment) {
|
|
1067
1085
|
return segment.getSegmentLevel() + 1;
|
|
1068
1086
|
}
|
|
@@ -1097,11 +1115,11 @@ DataTable.prototype.getSegmentValues = function(rids, partial) {
|
|
|
1097
1115
|
* @return {boolean} Return true if the given row is in the last segment
|
|
1098
1116
|
*/
|
|
1099
1117
|
DataTable.prototype._isLastSegment = function(at) {
|
|
1100
|
-
|
|
1118
|
+
let segmentSeparators = this._segments;
|
|
1101
1119
|
if(segmentSeparators) {
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
for(
|
|
1120
|
+
let rids = this._rids;
|
|
1121
|
+
let rowCount = rids.length;
|
|
1122
|
+
for(let r = at + 1; r < rowCount; ++r) {
|
|
1105
1123
|
if(segmentSeparators.containsSegment(rids[r])) {
|
|
1106
1124
|
return false;
|
|
1107
1125
|
}
|
|
@@ -1151,7 +1169,7 @@ DataTable.prototype.fillSegment = function(segmentId) {
|
|
|
1151
1169
|
*/
|
|
1152
1170
|
DataTable.prototype.fillSegments = function() {
|
|
1153
1171
|
if(this._segments) {
|
|
1154
|
-
|
|
1172
|
+
let dirty = this._segments.fillSegments(this._rids);
|
|
1155
1173
|
if(dirty) {
|
|
1156
1174
|
this.dispatchGlobalChange();
|
|
1157
1175
|
this.requestClassifying();
|
|
@@ -1168,7 +1186,7 @@ DataTable.prototype.fillSegments = function() {
|
|
|
1168
1186
|
*/
|
|
1169
1187
|
DataTable.prototype.addSegmentChild = function(segmentId, rid, dataId) {
|
|
1170
1188
|
if(this._segments) {
|
|
1171
|
-
|
|
1189
|
+
let dirty = this._segments.addSegmentChild(segmentId, rid, dataId);
|
|
1172
1190
|
if(dirty) {
|
|
1173
1191
|
this._sort(null);
|
|
1174
1192
|
this._dispatchPositionChange(); // Force rerendering, even if there is no position change
|
|
@@ -1187,7 +1205,7 @@ DataTable.prototype.addSegmentChild = function(segmentId, rid, dataId) {
|
|
|
1187
1205
|
*/
|
|
1188
1206
|
DataTable.prototype.addSegmentChildren = function(segmentId, rids, dataIds) {
|
|
1189
1207
|
if(this._segments) {
|
|
1190
|
-
|
|
1208
|
+
let dirty = this._segments.addSegmentChildren(segmentId, rids, dataIds);
|
|
1191
1209
|
if(dirty) {
|
|
1192
1210
|
this._sort(null);
|
|
1193
1211
|
this._dispatchPositionChange(); // Force rerendering, even if there is no position change
|
|
@@ -1205,7 +1223,7 @@ DataTable.prototype.addSegmentChildren = function(segmentId, rids, dataIds) {
|
|
|
1205
1223
|
*/
|
|
1206
1224
|
DataTable.prototype.removeSegmentChild = function(segmentId, rid) {
|
|
1207
1225
|
if(this._segments) {
|
|
1208
|
-
|
|
1226
|
+
let dirty = this._segments.removeSegmentChild(segmentId, rid);
|
|
1209
1227
|
if(dirty) {
|
|
1210
1228
|
this.dispatchGlobalChange();
|
|
1211
1229
|
this.requestClassifying();
|
|
@@ -1221,7 +1239,7 @@ DataTable.prototype.removeSegmentChild = function(segmentId, rid) {
|
|
|
1221
1239
|
*/
|
|
1222
1240
|
DataTable.prototype.removeSegmentChildren = function(segmentId, rids) {
|
|
1223
1241
|
if(this._segments) {
|
|
1224
|
-
|
|
1242
|
+
let dirty = this._segments.removeSegmentChildren(segmentId, rids);
|
|
1225
1243
|
if(dirty) {
|
|
1226
1244
|
this.dispatchGlobalChange();
|
|
1227
1245
|
this.requestClassifying();
|
|
@@ -1235,7 +1253,7 @@ DataTable.prototype.removeSegmentChildren = function(segmentId, rids) {
|
|
|
1235
1253
|
*/
|
|
1236
1254
|
DataTable.prototype.removeAllSegmentChildren = function() {
|
|
1237
1255
|
if(this._segments) {
|
|
1238
|
-
|
|
1256
|
+
let dirty = this._segments.removeAllSegmentChildren(); // This immediately remove all sub segments
|
|
1239
1257
|
if (dirty) {
|
|
1240
1258
|
this.dispatchGlobalChange();
|
|
1241
1259
|
}
|
|
@@ -1260,9 +1278,9 @@ DataTable.prototype.getSegmentIds = function() {
|
|
|
1260
1278
|
*/
|
|
1261
1279
|
DataTable.prototype.getSegmentChildIds = function(segmentId) {
|
|
1262
1280
|
if(this._segments) {
|
|
1263
|
-
|
|
1281
|
+
let segment = this._segments.getSegment(segmentId);
|
|
1264
1282
|
if(segment) {
|
|
1265
|
-
|
|
1283
|
+
let chdr = segment.getChildIds();
|
|
1266
1284
|
return chdr.length ? chdr : null;
|
|
1267
1285
|
}
|
|
1268
1286
|
}
|
|
@@ -1276,26 +1294,26 @@ DataTable.prototype.getSegmentChildIds = function(segmentId) {
|
|
|
1276
1294
|
* @return {boolean}
|
|
1277
1295
|
*/
|
|
1278
1296
|
DataTable.prototype.sortSeparators = function (sortLogics, sortOrders, cids) {
|
|
1279
|
-
|
|
1297
|
+
let dirty = false;
|
|
1280
1298
|
if(!this._segments){
|
|
1281
1299
|
return false;
|
|
1282
1300
|
}
|
|
1283
1301
|
if(typeof sortLogics === "function"){
|
|
1284
1302
|
return this.sortSegments(sortLogics);
|
|
1285
1303
|
}
|
|
1286
|
-
|
|
1304
|
+
let sortingDefs = DataTable._buildSortContext(
|
|
1287
1305
|
[],
|
|
1288
1306
|
cids,
|
|
1289
1307
|
sortOrders,
|
|
1290
1308
|
sortLogics
|
|
1291
1309
|
);
|
|
1292
|
-
|
|
1310
|
+
let defCount = sortingDefs ? sortingDefs.length : 0;
|
|
1293
1311
|
if(!defCount){
|
|
1294
1312
|
return dirty;
|
|
1295
1313
|
}
|
|
1296
1314
|
|
|
1297
|
-
|
|
1298
|
-
|
|
1315
|
+
let sortOrder = 0;
|
|
1316
|
+
let sortLogic, sortContext;
|
|
1299
1317
|
if(defCount > 1) {
|
|
1300
1318
|
sortLogic = DataTable._multiColumnSeparatorCompareLogic;
|
|
1301
1319
|
sortContext = sortingDefs;
|
|
@@ -1326,16 +1344,16 @@ DataTable.prototype.sortSegments = function (compare) {
|
|
|
1326
1344
|
this._segments.calcSegmentOrder(this._rids);
|
|
1327
1345
|
return false;
|
|
1328
1346
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1347
|
+
let rids = this._rids;
|
|
1348
|
+
let segments = this._segments;
|
|
1349
|
+
let segmentCount = segments.getSegmentCount();
|
|
1350
|
+
let segmentList = [];
|
|
1351
|
+
let origOrder = [];
|
|
1352
|
+
let itemCount = 0;
|
|
1353
|
+
let rowCount = rids.length;
|
|
1354
|
+
let rid = "";
|
|
1355
|
+
let segment = null;
|
|
1356
|
+
let i;
|
|
1339
1357
|
for(i = 0; i < rowCount; ++i) {
|
|
1340
1358
|
rid = rids[i];
|
|
1341
1359
|
segment = segments.getSegment(rid);
|
|
@@ -1352,12 +1370,12 @@ DataTable.prototype.sortSegments = function (compare) {
|
|
|
1352
1370
|
segmentList.sort(this._bySegmentSeparator);
|
|
1353
1371
|
this._userSegmentComparer = null;
|
|
1354
1372
|
|
|
1355
|
-
|
|
1373
|
+
let dirty = false;
|
|
1356
1374
|
for(i = 0; i < itemCount; ++i) {
|
|
1357
|
-
|
|
1375
|
+
let idx = origOrder[i];
|
|
1358
1376
|
rid = rids[idx];
|
|
1359
1377
|
segment = segmentList[i];
|
|
1360
|
-
|
|
1378
|
+
let newRid = segment.getId();
|
|
1361
1379
|
if(rid !== newRid) {
|
|
1362
1380
|
rids[idx] = newRid;
|
|
1363
1381
|
dirty = true;
|
|
@@ -1406,7 +1424,7 @@ DataTable.prototype.setClassificationSource = function(dc) {
|
|
|
1406
1424
|
*/
|
|
1407
1425
|
DataTable.prototype.setSegmentClassification = function(segmentId, fields) {
|
|
1408
1426
|
if(this._segments) {
|
|
1409
|
-
|
|
1427
|
+
let dirty = this._segments.setSegmentClassification(segmentId, fields);
|
|
1410
1428
|
if(dirty) {
|
|
1411
1429
|
return this.classifySegments();
|
|
1412
1430
|
}
|
|
@@ -1444,20 +1462,20 @@ DataTable.prototype._onClassifyingTimer = function() {
|
|
|
1444
1462
|
* @param {Object} e
|
|
1445
1463
|
*/
|
|
1446
1464
|
DataTable.prototype._onSubSegmentChanged = function(e) {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1465
|
+
let insertionList = /** @type{Array.<Segment>} */(e["insertionList"]);
|
|
1466
|
+
let removalList = /** @type{Array.<string>} */(e["removalList"]);
|
|
1467
|
+
|
|
1468
|
+
let dirty = false;
|
|
1469
|
+
let rows = this._rows;
|
|
1470
|
+
let clsSource = this._clsSource || rows;
|
|
1471
|
+
let rids = this._rids;
|
|
1472
|
+
let prevData = this._prevData;
|
|
1473
|
+
let i;
|
|
1474
|
+
|
|
1475
|
+
let removalCount = removalList.length;
|
|
1476
|
+
let removedRows = {};
|
|
1459
1477
|
for(i = 0; i < removalCount; i++) {
|
|
1460
|
-
|
|
1478
|
+
let rid = removalList[i];
|
|
1461
1479
|
if(rows[rid]) {
|
|
1462
1480
|
removedRows[rid] = prevData[rid] = rows[rid];
|
|
1463
1481
|
delete rows[rid];
|
|
@@ -1467,17 +1485,17 @@ DataTable.prototype._onSubSegmentChanged = function(e) {
|
|
|
1467
1485
|
}
|
|
1468
1486
|
}
|
|
1469
1487
|
|
|
1470
|
-
|
|
1488
|
+
let insertionCount = insertionList.length;
|
|
1471
1489
|
for(i = 0; i < insertionCount; i++) {
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1490
|
+
let segment = insertionList[i];
|
|
1491
|
+
let parentId = segment.getParentId();
|
|
1492
|
+
let segmentId = segment.getId();
|
|
1475
1493
|
|
|
1476
1494
|
if(!rows[segmentId]) {
|
|
1477
1495
|
prevData[segmentId] = {};
|
|
1478
1496
|
segment.setRowData(rows, clsSource);
|
|
1479
1497
|
|
|
1480
|
-
|
|
1498
|
+
let parentAt = rids.indexOf(parentId);
|
|
1481
1499
|
if(parentAt < 0 || parentAt + 1 >= rids.length) {
|
|
1482
1500
|
rids.push(segmentId);
|
|
1483
1501
|
} else {
|
|
@@ -1501,10 +1519,10 @@ DataTable.prototype._onSubSegmentChanged = function(e) {
|
|
|
1501
1519
|
* @return {boolean} Return true if there is any change, otherwise false
|
|
1502
1520
|
*/
|
|
1503
1521
|
DataTable.prototype._sort = function(sortingDefs) {
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1522
|
+
let rids = this._rids;
|
|
1523
|
+
let dataRows = this.getMultipleRowData(rids);
|
|
1524
|
+
let segmentValues = this.getSegmentValues(rids);
|
|
1525
|
+
let change = DataTable._performMultiLevelSorting(dataRows, sortingDefs, segmentValues);
|
|
1508
1526
|
|
|
1509
1527
|
if(change) {
|
|
1510
1528
|
this._rids = DataTable._reorderItems(rids, change);
|
|
@@ -1554,7 +1572,7 @@ DataTable.prototype.dump = function(opt_options) {
|
|
|
1554
1572
|
* @return {boolean} Return true if there is any change, and false otherwise
|
|
1555
1573
|
*/
|
|
1556
1574
|
DataTable.prototype._setData = function(rid, cid, value) {
|
|
1557
|
-
|
|
1575
|
+
let row = this.getRowData(rid);
|
|
1558
1576
|
|
|
1559
1577
|
if(!row) {
|
|
1560
1578
|
row = {};
|
|
@@ -1572,12 +1590,12 @@ DataTable.prototype._setData = function(rid, cid, value) {
|
|
|
1572
1590
|
* @returns {Array.<string>}
|
|
1573
1591
|
*/
|
|
1574
1592
|
DataTable.prototype._generateRids = function(len, opt_ridList) {
|
|
1575
|
-
|
|
1593
|
+
let r = 0, rids;
|
|
1576
1594
|
if(opt_ridList) {
|
|
1577
1595
|
rids = opt_ridList;
|
|
1578
1596
|
} else {
|
|
1579
1597
|
rids = [];
|
|
1580
|
-
|
|
1598
|
+
let rowCount = this._rids.length;
|
|
1581
1599
|
while(r < rowCount && r < len) {
|
|
1582
1600
|
rids.push(this._rids[r++]);
|
|
1583
1601
|
}
|
|
@@ -1645,7 +1663,7 @@ DataTable._positionChangeArg = {"globalChange": true, "positionChangeOnly": true
|
|
|
1645
1663
|
* @return {!Array.<Array>}
|
|
1646
1664
|
*/
|
|
1647
1665
|
DataTable._buildSortContext = function(out_defs, cids, sortOrders, logics, contextObj) {
|
|
1648
|
-
|
|
1666
|
+
let aryColumnIds, aryOrders;
|
|
1649
1667
|
if(Array.isArray(cids)) {
|
|
1650
1668
|
aryColumnIds = /** @type{Array.<string>} */(cids);
|
|
1651
1669
|
aryOrders = /** @type{Array.<string|number>} */(sortOrders);
|
|
@@ -1654,24 +1672,24 @@ DataTable._buildSortContext = function(out_defs, cids, sortOrders, logics, conte
|
|
|
1654
1672
|
aryOrders = (cids) ? [/** @type{string|number} */(sortOrders)] : [0];
|
|
1655
1673
|
}
|
|
1656
1674
|
|
|
1657
|
-
|
|
1658
|
-
|
|
1675
|
+
let logic = null;
|
|
1676
|
+
let logicMap = null;
|
|
1659
1677
|
if(typeof logics == "function") {
|
|
1660
1678
|
logic = logics;
|
|
1661
1679
|
} else {
|
|
1662
1680
|
logicMap = /** @type{Array.<Function>|Object.<string, DataTable.SortLogic>} */(logics);
|
|
1663
1681
|
}
|
|
1664
|
-
|
|
1682
|
+
let len = aryColumnIds.length;
|
|
1665
1683
|
out_defs.length = len;
|
|
1666
|
-
for(
|
|
1684
|
+
for(let c = len; --c >= 0;) {
|
|
1667
1685
|
if (Array.isArray(logicMap)) {
|
|
1668
1686
|
logic = logicMap[c];
|
|
1669
1687
|
}
|
|
1670
|
-
|
|
1688
|
+
let sortingDef = out_defs[c];
|
|
1671
1689
|
if(!sortingDef) {
|
|
1672
1690
|
sortingDef = out_defs[c] = new Array(5);
|
|
1673
1691
|
}
|
|
1674
|
-
|
|
1692
|
+
let columnId = aryColumnIds[c];
|
|
1675
1693
|
sortingDef[0] = columnId; // text field
|
|
1676
1694
|
sortingDef[1] = null; // Reserved for row data
|
|
1677
1695
|
sortingDef[2] = logic || logicMap[columnId] || logicMap["_default"]; // sort logic
|
|
@@ -1694,10 +1712,10 @@ DataTable._buildSortContext = function(out_defs, cids, sortOrders, logics, conte
|
|
|
1694
1712
|
* @return {number}
|
|
1695
1713
|
*/
|
|
1696
1714
|
DataTable._multiColumnCompareLogic = function(a, b, order, sortingDefs) {
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
for(
|
|
1700
|
-
|
|
1715
|
+
let count = sortingDefs.length;
|
|
1716
|
+
let result = 0;
|
|
1717
|
+
for(let c = 0; c < count; ++c) {
|
|
1718
|
+
let sortingDef = sortingDefs[c];
|
|
1701
1719
|
result = DataTable._singleColumnCompareLogic(a, b, sortingDef[3], sortingDef);
|
|
1702
1720
|
if(result) {
|
|
1703
1721
|
return result;
|
|
@@ -1716,7 +1734,7 @@ DataTable._multiColumnCompareLogic = function(a, b, order, sortingDefs) {
|
|
|
1716
1734
|
* @return {number}
|
|
1717
1735
|
*/
|
|
1718
1736
|
DataTable._singleColumnCompareLogic = function(a, b, order, sortingDef) {
|
|
1719
|
-
|
|
1737
|
+
let values = /** @type{Array} */(sortingDef[1]);
|
|
1720
1738
|
return /** @type{number} */(sortingDef[2](
|
|
1721
1739
|
values[a], // Value1
|
|
1722
1740
|
values[b], // Value2
|
|
@@ -1735,10 +1753,10 @@ DataTable._singleColumnCompareLogic = function(a, b, order, sortingDef) {
|
|
|
1735
1753
|
* @return {number}
|
|
1736
1754
|
*/
|
|
1737
1755
|
DataTable._multiColumnSeparatorCompareLogic = function(a, b, order, sortingDefs) {
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
for(
|
|
1741
|
-
|
|
1756
|
+
let count = sortingDefs.length;
|
|
1757
|
+
let result = 0;
|
|
1758
|
+
for(let c = 0; c < count; ++c) {
|
|
1759
|
+
let sortingDef = sortingDefs[c];
|
|
1742
1760
|
result = DataTable._singleColumnSeparatorCompareLogic(a, b, sortingDef[3], sortingDef);
|
|
1743
1761
|
if(result) {
|
|
1744
1762
|
return result;
|
|
@@ -1757,7 +1775,7 @@ DataTable._multiColumnSeparatorCompareLogic = function(a, b, order, sortingDefs)
|
|
|
1757
1775
|
* @return {number}
|
|
1758
1776
|
*/
|
|
1759
1777
|
DataTable._singleColumnSeparatorCompareLogic = function(a, b, order, sortingDef) {
|
|
1760
|
-
|
|
1778
|
+
let key = /** @type{string} */(sortingDef[0]);
|
|
1761
1779
|
return /** @type{number} */(sortingDef[2](
|
|
1762
1780
|
a[key], // Value1
|
|
1763
1781
|
b[key], // Value2
|
|
@@ -1774,20 +1792,20 @@ DataTable._singleColumnSeparatorCompareLogic = function(a, b, order, sortingDef)
|
|
|
1774
1792
|
* @return {Array.<number>} Returns new item positions if there is any change, otherwise returns null
|
|
1775
1793
|
*/
|
|
1776
1794
|
DataTable._performMultiLevelSorting = function(dataRows, sortingDefs, segmentValues) {
|
|
1777
|
-
|
|
1778
|
-
|
|
1795
|
+
let rowCount = dataRows ? dataRows.length : 0;
|
|
1796
|
+
let defCount = sortingDefs ? sortingDefs.length : 0;
|
|
1779
1797
|
if(!rowCount) {
|
|
1780
1798
|
return null;
|
|
1781
1799
|
}
|
|
1782
1800
|
|
|
1783
|
-
|
|
1801
|
+
let sortLogic;
|
|
1784
1802
|
// Populate data for each definition
|
|
1785
|
-
for(
|
|
1786
|
-
|
|
1787
|
-
|
|
1803
|
+
for(let c = 0; c < defCount; ++c) {
|
|
1804
|
+
let sortingDef = sortingDefs[c];
|
|
1805
|
+
let rows = sortingDef[1];
|
|
1788
1806
|
sortLogic = sortingDef[2];
|
|
1789
|
-
|
|
1790
|
-
|
|
1807
|
+
let rowSorting = sortLogic["rowSorting"];
|
|
1808
|
+
let r;
|
|
1791
1809
|
if(rowSorting) {
|
|
1792
1810
|
if(rows) {
|
|
1793
1811
|
rows.length = rowCount;
|
|
@@ -1803,7 +1821,7 @@ DataTable._performMultiLevelSorting = function(dataRows, sortingDefs, segmentVal
|
|
|
1803
1821
|
} else {
|
|
1804
1822
|
rows = sortingDef[1] = new Array(rowCount);
|
|
1805
1823
|
}
|
|
1806
|
-
|
|
1824
|
+
let columnId = sortingDef[0];
|
|
1807
1825
|
for(r = 0; r < rowCount; ++r) {
|
|
1808
1826
|
rows[r] = dataRows[r][columnId];
|
|
1809
1827
|
}
|
|
@@ -1811,7 +1829,7 @@ DataTable._performMultiLevelSorting = function(dataRows, sortingDefs, segmentVal
|
|
|
1811
1829
|
}
|
|
1812
1830
|
|
|
1813
1831
|
if(segmentValues) {
|
|
1814
|
-
|
|
1832
|
+
let segmentDef = [ // TODO: Make this static variable
|
|
1815
1833
|
"ROW_SEGMENT", // Dummy column id
|
|
1816
1834
|
segmentValues, // Segment values
|
|
1817
1835
|
DataTable._segmentComparer,
|
|
@@ -1831,8 +1849,8 @@ DataTable._performMultiLevelSorting = function(dataRows, sortingDefs, segmentVal
|
|
|
1831
1849
|
return null;
|
|
1832
1850
|
}
|
|
1833
1851
|
|
|
1834
|
-
|
|
1835
|
-
|
|
1852
|
+
let sortOrder = 0;
|
|
1853
|
+
let sortContext;
|
|
1836
1854
|
if(defCount > 1) {
|
|
1837
1855
|
sortLogic = DataTable._multiColumnCompareLogic;
|
|
1838
1856
|
sortContext = sortingDefs;
|
|
@@ -1856,12 +1874,12 @@ DataTable._performMultiLevelSorting = function(dataRows, sortingDefs, segmentVal
|
|
|
1856
1874
|
* @return {Array.<number>} Returns new item positions if there is any change, otherwise returns null
|
|
1857
1875
|
*/
|
|
1858
1876
|
DataTable._mergeSort = function(len, order, comparer, contextObj) {
|
|
1859
|
-
|
|
1877
|
+
let change = false;
|
|
1860
1878
|
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1879
|
+
let grpSize = 1;
|
|
1880
|
+
let iter, lhsFrom, rhsFrom, lhsTo, rhsTo;
|
|
1881
|
+
let subj = DataTable._createIndexArray(len);
|
|
1882
|
+
let obj = subj.slice();
|
|
1865
1883
|
|
|
1866
1884
|
while(grpSize <= len) {
|
|
1867
1885
|
iter = rhsTo = 0; // start from 0
|
|
@@ -1903,7 +1921,7 @@ DataTable._mergeSort = function(len, order, comparer, contextObj) {
|
|
|
1903
1921
|
}
|
|
1904
1922
|
}
|
|
1905
1923
|
|
|
1906
|
-
|
|
1924
|
+
let tmp = subj;
|
|
1907
1925
|
subj = obj;
|
|
1908
1926
|
obj = tmp;
|
|
1909
1927
|
grpSize <<= 1;
|
|
@@ -1921,7 +1939,7 @@ DataTable._mergeSort = function(len, order, comparer, contextObj) {
|
|
|
1921
1939
|
*/
|
|
1922
1940
|
DataTable._reorderItems = function (ary, orders) {
|
|
1923
1941
|
if(orders) {
|
|
1924
|
-
for(
|
|
1942
|
+
for(let i = ary.length; --i >= 0;) {
|
|
1925
1943
|
orders[i] = ary[orders[i]];
|
|
1926
1944
|
}
|
|
1927
1945
|
return orders;
|
|
@@ -1936,7 +1954,7 @@ DataTable._reorderItems = function (ary, orders) {
|
|
|
1936
1954
|
* @return {!Array.<number>}
|
|
1937
1955
|
*/
|
|
1938
1956
|
DataTable._createIndexArray = function(len) {
|
|
1939
|
-
|
|
1957
|
+
let ary = DataTable._idxAryMap[len];
|
|
1940
1958
|
if(!ary) {
|
|
1941
1959
|
if(DataTable._idxAryCount > 50) { // Clear cache to avoid caching huge memory
|
|
1942
1960
|
DataTable._idxAryMap = {};
|
|
@@ -1945,7 +1963,7 @@ DataTable._createIndexArray = function(len) {
|
|
|
1945
1963
|
ary = DataTable._idxAryMap[len] = new Array(len);
|
|
1946
1964
|
DataTable._idxAryCount++;
|
|
1947
1965
|
|
|
1948
|
-
for(
|
|
1966
|
+
for(let i = 0; i < len; ++i) {
|
|
1949
1967
|
ary[i] = i;
|
|
1950
1968
|
}
|
|
1951
1969
|
}
|