@refinitiv-ui/efx-grid 6.0.103 → 6.0.105
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/core/dist/core.js +14 -137
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/DataCache.d.ts +0 -8
- package/lib/core/es6/data/DataCache.js +13 -136
- package/lib/core/es6/grid/Core.js +1 -1
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +356 -734
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/FieldDefinition.js +4 -4
- package/lib/rt-grid/es6/Grid.d.ts +1 -1
- package/lib/rt-grid/es6/Grid.js +8 -49
- package/lib/rt-grid/es6/RowDefinition.d.ts +5 -3
- package/lib/rt-grid/es6/RowDefinition.js +49 -20
- package/lib/tr-grid-column-fitter/es6/ColumnFitter.js +523 -708
- package/lib/tr-grid-column-resizing/es6/ColumnResizing.d.ts +16 -16
- package/lib/tr-grid-column-resizing/es6/ColumnResizing.js +131 -109
- package/lib/types/es6/ColumnResizing.d.ts +16 -16
- package/lib/types/es6/Core/data/DataCache.d.ts +0 -8
- package/lib/types/es6/RealtimeGrid/FieldDefinition.d.ts +1 -1
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +1 -1
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +5 -3
- package/lib/versions.json +2 -2
- package/package.json +3 -2
@@ -6,25 +6,25 @@ import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
|
|
6
6
|
declare namespace ColumnResizingPlugin {
|
7
7
|
|
8
8
|
type Options = {
|
9
|
-
preserveProportion?: boolean,
|
10
|
-
preserveGridSize?: boolean,
|
11
|
-
noResizing?: boolean,
|
12
|
-
columnResized?: ((...params: any[]) => any),
|
13
|
-
dblClicked?: ((...params: any[]) => any),
|
14
|
-
dragStart?: ((...params: any[]) => any),
|
15
|
-
dragEnd?: ((...params: any[]) => any)
|
9
|
+
preserveProportion?: boolean|null,
|
10
|
+
preserveGridSize?: boolean|null,
|
11
|
+
noResizing?: boolean|null,
|
12
|
+
columnResized?: ((...params: any[]) => any)|null,
|
13
|
+
dblClicked?: ((...params: any[]) => any)|null,
|
14
|
+
dragStart?: ((...params: any[]) => any)|null,
|
15
|
+
dragEnd?: ((...params: any[]) => any)|null
|
16
16
|
};
|
17
17
|
|
18
18
|
type ColumnOptions = {
|
19
|
-
noResizing?: boolean,
|
20
|
-
defaultWidth?: number
|
19
|
+
noResizing?: boolean|null,
|
20
|
+
defaultWidth?: number|null
|
21
21
|
};
|
22
22
|
|
23
23
|
}
|
24
24
|
|
25
25
|
declare class ColumnResizingPlugin extends GridPlugin {
|
26
26
|
|
27
|
-
constructor(options?: ColumnResizingPlugin.Options);
|
27
|
+
constructor(options?: ColumnResizingPlugin.Options|null);
|
28
28
|
|
29
29
|
public getName(): string;
|
30
30
|
|
@@ -40,15 +40,15 @@ declare class ColumnResizingPlugin extends GridPlugin {
|
|
40
40
|
|
41
41
|
public getConfigObject(gridOptions?: any): any;
|
42
42
|
|
43
|
-
public disableResizing(colIndex: number, opt_disabled?: boolean): void;
|
43
|
+
public disableResizing(colIndex: number, opt_disabled?: boolean|null): void;
|
44
44
|
|
45
45
|
public getDraggedColumnIndex(): number;
|
46
46
|
|
47
47
|
public getDraggedAnchorX(): number;
|
48
48
|
|
49
|
-
public setColumnWidths(cols: (number)[], width: (number)[]|number, opt_scalable?: boolean): void;
|
49
|
+
public setColumnWidths(cols: (number)[]|null, width: (number)[]|number|null, opt_scalable?: boolean|null): void;
|
50
50
|
|
51
|
-
public setAllColumnWidths(colWidth: number, scalability?: boolean): boolean;
|
51
|
+
public setAllColumnWidths(colWidth: number, scalability?: boolean|null): boolean;
|
52
52
|
|
53
53
|
public getColumnWidths(): (number)[]|null;
|
54
54
|
|
@@ -56,11 +56,11 @@ declare class ColumnResizingPlugin extends GridPlugin {
|
|
56
56
|
|
57
57
|
public getColumnSizeStates(): (any)[]|null;
|
58
58
|
|
59
|
-
public setColumnSizeStates(columns: (any)[]|string): void;
|
59
|
+
public setColumnSizeStates(columns: (any)[]|string|null): void;
|
60
60
|
|
61
|
-
public enablePipeHandleMode(bool?: boolean): void;
|
61
|
+
public enablePipeHandleMode(bool?: boolean|null): void;
|
62
62
|
|
63
|
-
public enableHandlebarMode(bool?: boolean): void;
|
63
|
+
public enableHandlebarMode(bool?: boolean|null): void;
|
64
64
|
|
65
65
|
}
|
66
66
|
|
@@ -39,8 +39,8 @@ import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
|
|
39
39
|
* @extends {GridPlugin}
|
40
40
|
* @param {ColumnResizingPlugin~Options=} options
|
41
41
|
*/
|
42
|
-
|
43
|
-
|
42
|
+
let ColumnResizingPlugin = function (options) {
|
43
|
+
let t = this;
|
44
44
|
t._onPreSectionRender = t._onPreSectionRender.bind(t);
|
45
45
|
t._requestResizerUpdate = t._requestResizerUpdate.bind(t);
|
46
46
|
t._updateResizers = t._updateResizers.bind(t);
|
@@ -265,7 +265,7 @@ ColumnResizingPlugin.prototype.initialize = function (host, options) {
|
|
265
265
|
* @param {Object} host core grid object
|
266
266
|
*/
|
267
267
|
ColumnResizingPlugin.prototype.unload = function (host) {
|
268
|
-
|
268
|
+
let at = this._hosts.indexOf(host);
|
269
269
|
if(at < 0) { return; }
|
270
270
|
|
271
271
|
this._hosts.splice(at, 1);
|
@@ -280,36 +280,29 @@ ColumnResizingPlugin.prototype.unload = function (host) {
|
|
280
280
|
this._updateTimer = 0;
|
281
281
|
}
|
282
282
|
|
283
|
-
|
283
|
+
let titleSect = host.getSection("title");
|
284
284
|
if(titleSect) {
|
285
|
-
for(
|
286
|
-
|
285
|
+
for(let c = host.getColumnCount(); --c >= 0;) {
|
286
|
+
let col = titleSect.getColumn(c);
|
287
287
|
if(col._resizers) {
|
288
|
-
|
289
|
-
for(
|
290
|
-
|
291
|
-
if(resizer.dispose) {
|
292
|
-
resizer.dispose();
|
293
|
-
} else {
|
294
|
-
Dom.removeParent(resizer);
|
295
|
-
}
|
288
|
+
let len = col._resizers.length;
|
289
|
+
for(let i = 0; i < len; ++i) {
|
290
|
+
Dom.removeParent(col._resizers[i]);
|
296
291
|
}
|
297
292
|
col._resizers = null;
|
298
293
|
}
|
299
294
|
}
|
300
295
|
}
|
301
296
|
|
302
|
-
|
303
|
-
this._compositeGrid = null;
|
304
|
-
}
|
297
|
+
this._dispose();
|
305
298
|
};
|
306
299
|
/** @public
|
307
300
|
* @param {Object=} options
|
308
301
|
*/
|
309
302
|
ColumnResizingPlugin.prototype.config = function (options) {
|
310
303
|
if(!options) { return; }
|
311
|
-
|
312
|
-
|
304
|
+
let host = this._hosts[this._hosts.length - 1];
|
305
|
+
let pluginOption = options["columnResizing"];
|
313
306
|
if(pluginOption) {
|
314
307
|
if(pluginOption["preserveProportion"]) {
|
315
308
|
this._keepProportion = true;
|
@@ -339,11 +332,11 @@ ColumnResizingPlugin.prototype.config = function (options) {
|
|
339
332
|
this.addListener(pluginOption, "dragEnd");
|
340
333
|
}
|
341
334
|
|
342
|
-
|
335
|
+
let columns = options["columns"];
|
343
336
|
if(!columns) { return; }
|
344
337
|
|
345
|
-
|
346
|
-
for(
|
338
|
+
let len = columns.length;
|
339
|
+
for(let c = 0; c < len; ++c) {
|
347
340
|
this._configColumn(host, c, columns[c]);
|
348
341
|
}
|
349
342
|
};
|
@@ -353,32 +346,32 @@ ColumnResizingPlugin.prototype.config = function (options) {
|
|
353
346
|
* @return {!Object}
|
354
347
|
*/
|
355
348
|
ColumnResizingPlugin.prototype.getConfigObject = function (gridOptions) {
|
356
|
-
|
349
|
+
let obj = gridOptions || {};
|
357
350
|
|
358
|
-
|
351
|
+
let columns = obj.columns;
|
359
352
|
if (!columns) {
|
360
353
|
columns = obj.columns = [];
|
361
354
|
}
|
362
355
|
|
363
|
-
|
364
|
-
for (
|
365
|
-
|
356
|
+
let len = this.getColumnCount();
|
357
|
+
for (let i = 0; i < len; ++i) {
|
358
|
+
let column = columns[i];
|
366
359
|
if (!column) {
|
367
360
|
column = columns[i] = {};
|
368
361
|
}
|
369
362
|
|
370
|
-
|
363
|
+
let noResizing = this._getColumnOption(i, 'noResizing', this._hosts[0]);
|
371
364
|
if (noResizing) {
|
372
365
|
column.noResizing = noResizing;
|
373
366
|
}
|
374
367
|
|
375
|
-
|
368
|
+
let defaultWidth = this._getColumnOption(i, 'defaultWidth', this._hosts[0]);
|
376
369
|
if (typeof defaultWidth == "number") {
|
377
370
|
column.defaultWidth = defaultWidth;
|
378
371
|
}
|
379
372
|
}
|
380
373
|
|
381
|
-
|
374
|
+
let extOptions = obj.columnResizing;
|
382
375
|
if (!extOptions) {
|
383
376
|
extOptions = obj.columnResizing = {};
|
384
377
|
}
|
@@ -401,7 +394,7 @@ ColumnResizingPlugin.prototype._configColumn = function(host, colIndex, columnCo
|
|
401
394
|
if(columnConfig["noResizing"]) {
|
402
395
|
this._newColumnData(colIndex)["noResizing"] = true;
|
403
396
|
}
|
404
|
-
|
397
|
+
let num = columnConfig["defaultWidth"];
|
405
398
|
if(typeof num == "number") {
|
406
399
|
this._newColumnData(colIndex)["defaultWidth"] = num;
|
407
400
|
if(host) {
|
@@ -416,7 +409,7 @@ ColumnResizingPlugin.prototype._configColumn = function(host, colIndex, columnCo
|
|
416
409
|
*/
|
417
410
|
ColumnResizingPlugin.prototype._afterInit = function () {
|
418
411
|
if(this._compositeGrid) {
|
419
|
-
|
412
|
+
let core = this._compositeGrid.getCoreGrid();
|
420
413
|
core.unloadPlugin("ResizableTitlePlugin");
|
421
414
|
}
|
422
415
|
};
|
@@ -427,10 +420,10 @@ ColumnResizingPlugin.prototype._afterInit = function () {
|
|
427
420
|
* @param {boolean=} opt_disabled
|
428
421
|
*/
|
429
422
|
ColumnResizingPlugin.prototype.disableResizing = function(colIndex, opt_disabled) {
|
430
|
-
|
423
|
+
let colData = this._newColumnData(colIndex);
|
431
424
|
colData["noResizing"] = opt_disabled !== false;
|
432
425
|
|
433
|
-
for(
|
426
|
+
for(let i = this._hosts.length; --i >= 0;) {
|
434
427
|
this._updateResizerCount(this._hosts[i]);
|
435
428
|
}
|
436
429
|
};
|
@@ -456,14 +449,14 @@ ColumnResizingPlugin.prototype.getDraggedAnchorX = function() {
|
|
456
449
|
* @param {boolean=} opt_scalable If not defined false value is used instead
|
457
450
|
*/
|
458
451
|
ColumnResizingPlugin.prototype.setColumnWidths = function (cols, width, opt_scalable) {
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
for (
|
452
|
+
let colCount = this.getColumnCount();
|
453
|
+
let widths = new Array(colCount);
|
454
|
+
let isNumber = typeof width === "number";
|
455
|
+
for (let c = 0; c < cols.length; c++) {
|
463
456
|
widths[cols[c]] = isNumber ? width : width[c];
|
464
457
|
}
|
465
|
-
|
466
|
-
for(
|
458
|
+
let host;
|
459
|
+
for(let i = this._hosts.length; --i >= 0;) {
|
467
460
|
host = this._hosts[i];
|
468
461
|
host.setColumnWidths(widths, opt_scalable);
|
469
462
|
}
|
@@ -476,13 +469,13 @@ ColumnResizingPlugin.prototype.setColumnWidths = function (cols, width, opt_scal
|
|
476
469
|
* @return {boolean} True if there is any changed
|
477
470
|
*/
|
478
471
|
ColumnResizingPlugin.prototype.setAllColumnWidths = function (colWidth, scalability) {
|
479
|
-
|
480
|
-
|
481
|
-
|
472
|
+
let colCount = this.getColumnCount();
|
473
|
+
let widths = new Array(colCount);
|
474
|
+
let i;
|
482
475
|
for (i = 0; i < colCount; i++) {
|
483
476
|
widths[i] = colWidth;
|
484
477
|
}
|
485
|
-
|
478
|
+
let host, dirty = false;
|
486
479
|
for(i = this._hosts.length; --i >= 0;) {
|
487
480
|
host = this._hosts[i];
|
488
481
|
dirty |= host.setColumnWidths(widths, scalability);
|
@@ -495,9 +488,9 @@ ColumnResizingPlugin.prototype.setAllColumnWidths = function (colWidth, scalabil
|
|
495
488
|
* @returns {Array.<number>} Array of width
|
496
489
|
*/
|
497
490
|
ColumnResizingPlugin.prototype.getColumnWidths = function () {
|
498
|
-
|
499
|
-
|
500
|
-
for (
|
491
|
+
let colCount = this.getColumnCount();
|
492
|
+
let host = this._hosts[0], out = new Array(colCount);
|
493
|
+
for (let i = 0; i < colCount; i++) {
|
501
494
|
out[i] = host.getColumnWidth(i);
|
502
495
|
}
|
503
496
|
return out;
|
@@ -508,10 +501,10 @@ ColumnResizingPlugin.prototype.getColumnWidths = function () {
|
|
508
501
|
* @returns {boolean} True if there is any changed
|
509
502
|
*/
|
510
503
|
ColumnResizingPlugin.prototype.resetAllColumnsToDefaultWidth = function () {
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
for (
|
504
|
+
let dirty = false;
|
505
|
+
let hosts = this._hosts;
|
506
|
+
let host;
|
507
|
+
for (let i = 0; i < hosts.length; i++ ) {
|
515
508
|
host = hosts[i];
|
516
509
|
dirty |= host.resetColumnWidths();
|
517
510
|
}
|
@@ -523,9 +516,9 @@ ColumnResizingPlugin.prototype.resetAllColumnsToDefaultWidth = function () {
|
|
523
516
|
* @returns {Array.<Object>} Columns state
|
524
517
|
*/
|
525
518
|
ColumnResizingPlugin.prototype.getColumnSizeStates = function () {
|
526
|
-
|
527
|
-
|
528
|
-
for (
|
519
|
+
let colCount = this.getColumnCount();
|
520
|
+
let host = this._hosts[0], out = new Array(colCount);
|
521
|
+
for (let i = 0; i < colCount; i++) {
|
529
522
|
out[i] = {
|
530
523
|
width: host.getColumnWidth(i),
|
531
524
|
scalability: host.getColumnScalability(i)
|
@@ -540,7 +533,7 @@ ColumnResizingPlugin.prototype.getColumnSizeStates = function () {
|
|
540
533
|
* @param {Array.<Object>|string} columns Array or string
|
541
534
|
*/
|
542
535
|
ColumnResizingPlugin.prototype.setColumnSizeStates = function (columns) {
|
543
|
-
|
536
|
+
let host = this._hosts[0];
|
544
537
|
|
545
538
|
if (typeof columns === 'string') {
|
546
539
|
columns = JSON.parse(columns);
|
@@ -557,9 +550,9 @@ ColumnResizingPlugin.prototype.setColumnSizeStates = function (columns) {
|
|
557
550
|
* @param {boolean=} bool
|
558
551
|
*/
|
559
552
|
ColumnResizingPlugin.prototype.enablePipeHandleMode = function(bool) {
|
560
|
-
|
561
|
-
|
562
|
-
for(
|
553
|
+
let pipe = this._pipe = (bool !== false);
|
554
|
+
let len = this._hosts.length;
|
555
|
+
for(let i = 0; i < len; ++i) {
|
563
556
|
this._hosts[i].enableClass("tr-pipe-resizer", pipe);
|
564
557
|
}
|
565
558
|
};
|
@@ -567,10 +560,10 @@ ColumnResizingPlugin.prototype.enablePipeHandleMode = function(bool) {
|
|
567
560
|
* @param {boolean=} bool
|
568
561
|
*/
|
569
562
|
ColumnResizingPlugin.prototype.enableHandlebarMode = function(bool) {
|
570
|
-
|
563
|
+
let enabled = this._hbMode = (bool !== false);
|
571
564
|
|
572
565
|
if(enabled) {
|
573
|
-
|
566
|
+
let csp = this._getCSP();
|
574
567
|
if(csp) {
|
575
568
|
csp.listen("selectionChanged", this._updateHandlebar);
|
576
569
|
} else {
|
@@ -599,8 +592,8 @@ ColumnResizingPlugin.prototype._updateResizers = function () {
|
|
599
592
|
if(this._hbMode) {
|
600
593
|
this._updateHandlebar();
|
601
594
|
} else {
|
602
|
-
for(
|
603
|
-
|
595
|
+
for(let i = this._hosts.length; --i >= 0;) {
|
596
|
+
let host = this._hosts[i];
|
604
597
|
this._updateResizerCount(host);
|
605
598
|
}
|
606
599
|
}
|
@@ -620,7 +613,7 @@ ColumnResizingPlugin.prototype._onPreSectionRender = function (e) {
|
|
620
613
|
*/
|
621
614
|
ColumnResizingPlugin.prototype._onTimer = function() {
|
622
615
|
if(this._hbMode) {
|
623
|
-
|
616
|
+
let csp = this._getCSP();
|
624
617
|
if(csp) {
|
625
618
|
csp.listen("selectionChanged", this._updateHandlebar);
|
626
619
|
}
|
@@ -633,8 +626,8 @@ ColumnResizingPlugin.prototype._onTimer = function() {
|
|
633
626
|
*/
|
634
627
|
ColumnResizingPlugin.prototype._onColumnAdded = function(e) {
|
635
628
|
if(e.context && e.colIndex != null) {
|
636
|
-
for(
|
637
|
-
|
629
|
+
for(let i = this._hosts.length; --i >= 0;) {
|
630
|
+
let host = this._hosts[i];
|
638
631
|
this._configColumn(host, e.colIndex, e.context);
|
639
632
|
}
|
640
633
|
}
|
@@ -645,7 +638,7 @@ ColumnResizingPlugin.prototype._onColumnAdded = function(e) {
|
|
645
638
|
ColumnResizingPlugin.prototype._onDragStart = function (e) {
|
646
639
|
if (this._dragIndex >= 0) { return; }
|
647
640
|
|
648
|
-
|
641
|
+
let host = this._getDraggedGrid(e);
|
649
642
|
this._dragIndex = this._getResizerIndex(host, e);
|
650
643
|
if (this._dragIndex < 0) { return; }
|
651
644
|
|
@@ -658,7 +651,7 @@ ColumnResizingPlugin.prototype._onDragStart = function (e) {
|
|
658
651
|
window.addEventListener("mouseup", this._onDragEnd);
|
659
652
|
}
|
660
653
|
|
661
|
-
|
654
|
+
let gridParent = host.getElement().parentElement;
|
662
655
|
|
663
656
|
gridParent.classList.add("tr-dragging"); // Prevent text selection
|
664
657
|
gridParent.classList.add("tr-resize-cursor");
|
@@ -697,9 +690,9 @@ ColumnResizingPlugin.prototype._onDrag = function (e) {
|
|
697
690
|
return;
|
698
691
|
}
|
699
692
|
|
700
|
-
|
701
|
-
|
702
|
-
|
693
|
+
let diff = this._diffX = this._getAnchorX(e) - this._anchorX;
|
694
|
+
let width = this._draggedGrid.getColumnWidth(this._dragIndex);
|
695
|
+
let minWidth = this._draggedGrid.getMinimumColumnWidth(this._dragIndex);
|
703
696
|
|
704
697
|
if (width + diff < minWidth) {
|
705
698
|
diff = minWidth - width;
|
@@ -716,7 +709,7 @@ ColumnResizingPlugin.prototype._onDragEnd = function (e) {
|
|
716
709
|
window.removeEventListener("mousemove", this._onDrag);
|
717
710
|
window.removeEventListener("mouseup", this._onDragEnd);
|
718
711
|
|
719
|
-
|
712
|
+
let parentElement = this._guideline.parentElement;
|
720
713
|
if (parentElement) {
|
721
714
|
parentElement.classList.remove("tr-dragging");
|
722
715
|
parentElement.classList.remove("tr-resize-cursor");
|
@@ -729,9 +722,9 @@ ColumnResizingPlugin.prototype._onDragEnd = function (e) {
|
|
729
722
|
this._activeResizer = null;
|
730
723
|
|
731
724
|
if(this._diffX) { // There must be some change after dragging
|
732
|
-
|
733
|
-
|
734
|
-
|
725
|
+
let diff = this._diffX;
|
726
|
+
let minWidth = this._draggedGrid.getMinimumColumnWidth(this._dragIndex);
|
727
|
+
let newWidth = this._draggedGrid.getColumnWidth(this._dragIndex) + (diff / this._draggedGrid["zoomFactor"]);
|
735
728
|
if (newWidth < minWidth) { newWidth = minWidth; }
|
736
729
|
|
737
730
|
if (this._keepProportion) {
|
@@ -743,7 +736,7 @@ ColumnResizingPlugin.prototype._onDragEnd = function (e) {
|
|
743
736
|
"scalability": true
|
744
737
|
});
|
745
738
|
} else {
|
746
|
-
|
739
|
+
let cols = this._getResizingCols(this._dragIndex);
|
747
740
|
this.setColumnWidths(cols, newWidth);
|
748
741
|
|
749
742
|
this._dispatch("columnResized", {
|
@@ -767,20 +760,20 @@ ColumnResizingPlugin.prototype._onDragEnd = function (e) {
|
|
767
760
|
* @param {Event} e
|
768
761
|
*/
|
769
762
|
ColumnResizingPlugin.prototype._onDblClick = function(e){
|
770
|
-
|
771
|
-
|
772
|
-
|
763
|
+
let host = this.getRelativeGrid(e);
|
764
|
+
let colIndex = this._getResizerIndex(host, e);
|
765
|
+
let plugin = this._getPlugin("ColumnFitterPlugin");
|
773
766
|
if(!plugin) {
|
774
767
|
plugin = this._getPlugin("ColumnWidthAdjustingPlugin");
|
775
768
|
}
|
776
769
|
|
777
770
|
if(plugin) {
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
for(
|
771
|
+
let cols = this._getResizingCols(colIndex);
|
772
|
+
let widths = [];
|
773
|
+
let index;
|
774
|
+
for(let i = cols.length; --i >= 0;) {
|
782
775
|
index = cols[i];
|
783
|
-
|
776
|
+
let defaultW = this._getColumnOption(index, "defaultWidth");
|
784
777
|
widths[i] = (defaultW != null) ? defaultW : plugin["getAdjustedColumnWidth"](index);
|
785
778
|
}
|
786
779
|
|
@@ -799,22 +792,22 @@ ColumnResizingPlugin.prototype._updateHandlebar = function(e) {
|
|
799
792
|
return;
|
800
793
|
}
|
801
794
|
|
802
|
-
|
795
|
+
let csp = this._getCSP();
|
803
796
|
if(!csp) {
|
804
797
|
return;
|
805
798
|
}
|
806
799
|
|
807
|
-
|
800
|
+
let sels = csp.getSelectedColumns();
|
808
801
|
|
809
|
-
|
802
|
+
let showHandlebar = sels.length === 1;
|
810
803
|
if(showHandlebar) {
|
811
804
|
if(!this._handlebar) {
|
812
805
|
this._handlebar = this._newResizer("tr-handlebar");
|
813
806
|
this._guideline.classList.add("tr-hb-guideline");
|
814
807
|
this._guideline.appendChild(this._handlebar);
|
815
808
|
}
|
816
|
-
|
817
|
-
|
809
|
+
let colIndex = this._handlebar._colIndex = sels[0];
|
810
|
+
let grid = null;
|
818
811
|
if(e) {
|
819
812
|
grid = this._handlebar._grid = e.grid;
|
820
813
|
} else {
|
@@ -846,7 +839,7 @@ ColumnResizingPlugin._stopPropagation = function (e) {
|
|
846
839
|
* @return {ColumnSelectionPlugin}
|
847
840
|
*/
|
848
841
|
ColumnResizingPlugin.prototype._getCSP = function () {
|
849
|
-
|
842
|
+
let csp = this._getPlugin("ColumnSelectionPlugin");
|
850
843
|
if(csp && csp.isEnabled()) {
|
851
844
|
return /** @type{ColumnSelectionPlugin} */(csp);
|
852
845
|
} else {
|
@@ -861,15 +854,15 @@ ColumnResizingPlugin.prototype._updateResizerCount = function (host) {
|
|
861
854
|
return;
|
862
855
|
}
|
863
856
|
|
864
|
-
|
857
|
+
let titleSect = host.getSection("title");
|
865
858
|
if(!titleSect) {
|
866
859
|
return;
|
867
860
|
}
|
868
|
-
|
869
|
-
|
861
|
+
let colCount = host.getColumnCount();
|
862
|
+
let c, rowCount, col, boxes;
|
870
863
|
// Normal mode and Pipe mode
|
871
|
-
|
872
|
-
for (
|
864
|
+
let titleSects = host.getAllSections("title");
|
865
|
+
for (let i = 0; i < titleSects.length; i++) {
|
873
866
|
titleSect = titleSects[i];
|
874
867
|
for (c = 0; c < colCount; ++c) {
|
875
868
|
rowCount = titleSect.getRowCount();
|
@@ -878,21 +871,21 @@ ColumnResizingPlugin.prototype._updateResizerCount = function (host) {
|
|
878
871
|
if (!boxes) {
|
879
872
|
boxes = col._resizers = [];
|
880
873
|
}
|
881
|
-
for (
|
882
|
-
|
883
|
-
|
884
|
-
|
874
|
+
for (let j = 0; j < rowCount; j++) {
|
875
|
+
let disabled = false;
|
876
|
+
let cell = titleSect.getCell(c, j); // TODO: This can be optimized
|
877
|
+
let cellColSpan = titleSect.getCellColSpan(c, j);
|
885
878
|
if(cellColSpan){
|
886
|
-
|
879
|
+
let lastSpanCol = c + cellColSpan - 1;
|
887
880
|
disabled = this._getColumnOption(lastSpanCol, "noResizing");
|
888
881
|
} else {
|
889
882
|
disabled = this._getColumnOption(c, "noResizing");
|
890
883
|
}
|
891
|
-
|
884
|
+
let box = cell._resizer;
|
892
885
|
if (!box) {
|
893
886
|
box = this._newResizer();
|
894
887
|
cell._resizer = box; // Cache to prevent repeating creation
|
895
|
-
|
888
|
+
let cellElem = cell.getElement();
|
896
889
|
cellElem.insertBefore(box, cellElem.firstChild);
|
897
890
|
boxes.push(box);
|
898
891
|
}
|
@@ -907,7 +900,7 @@ ColumnResizingPlugin.prototype._updateResizerCount = function (host) {
|
|
907
900
|
* @return {!Element}
|
908
901
|
*/
|
909
902
|
ColumnResizingPlugin.prototype._newResizer = function (classStr) {
|
910
|
-
|
903
|
+
let box = Dom.div(classStr ? classStr : "resizer");
|
911
904
|
box.setAttribute("draggable", "true");
|
912
905
|
box.addEventListener("mousedown", ColumnResizingPlugin._stopPropagation);
|
913
906
|
box.addEventListener("click", ColumnResizingPlugin._stopPropagation);
|
@@ -946,15 +939,15 @@ ColumnResizingPlugin.prototype._getResizerIndex = function (host, e) {
|
|
946
939
|
}
|
947
940
|
}
|
948
941
|
|
949
|
-
|
942
|
+
let box = e["currentTarget"];
|
950
943
|
if (box._disabled) { // disabled is an internal flag
|
951
944
|
return -1;
|
952
945
|
}
|
953
946
|
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
947
|
+
let pos = host.getRelativePosition(e);
|
948
|
+
let colIndex = pos.colIndex;
|
949
|
+
let rowIndex = pos.rowIndex;
|
950
|
+
let colSpan = pos["section"].getCellColSpan(colIndex, rowIndex);
|
958
951
|
return (colIndex != null) ? colIndex + colSpan - 1 : -1;
|
959
952
|
};
|
960
953
|
/** @private
|
@@ -972,9 +965,9 @@ ColumnResizingPlugin.prototype._getColumnRight = function (host, colIndex) {
|
|
972
965
|
* @return {Array.<number>}
|
973
966
|
*/
|
974
967
|
ColumnResizingPlugin.prototype._getResizingCols = function (clickIndex) {
|
975
|
-
|
968
|
+
let csp = this._getCSP();
|
976
969
|
if(csp) {
|
977
|
-
|
970
|
+
let cols = csp["getSelectedColumns"]();
|
978
971
|
if(cols.indexOf(clickIndex) >= 0) { // if clickIndex does not exist in selected columns then return clickIndex.
|
979
972
|
return cols;
|
980
973
|
}
|
@@ -982,6 +975,35 @@ ColumnResizingPlugin.prototype._getResizingCols = function (clickIndex) {
|
|
982
975
|
return [clickIndex];
|
983
976
|
};
|
984
977
|
|
978
|
+
/** @public
|
979
|
+
* @ignore
|
980
|
+
* @return {Object}
|
981
|
+
*/
|
982
|
+
ColumnResizingPlugin.prototype._getEventHandlers = function () {
|
983
|
+
return {
|
984
|
+
"dragStart": this._onDragStart,
|
985
|
+
"drag": this._onDrag,
|
986
|
+
"dragEnd": this._onDragEnd,
|
987
|
+
"dblClick": this._onDblClick
|
988
|
+
};
|
989
|
+
};
|
990
|
+
/** @public
|
991
|
+
* @ignore
|
992
|
+
* @param {number} colIndex
|
993
|
+
* @return {Array.<Element>}
|
994
|
+
*/
|
995
|
+
ColumnResizingPlugin.prototype.getResizers = function (colIndex) {
|
996
|
+
var host = this._hosts[0];
|
997
|
+
let titleSect = host ? host.getSection("title") : null;
|
998
|
+
if(titleSect) {
|
999
|
+
let col = titleSect.getColumn(colIndex);
|
1000
|
+
if(col) {
|
1001
|
+
return col._resizers || null;
|
1002
|
+
}
|
1003
|
+
}
|
1004
|
+
return null;
|
1005
|
+
};
|
1006
|
+
|
985
1007
|
|
986
1008
|
|
987
1009
|
export default ColumnResizingPlugin;
|
@@ -6,25 +6,25 @@ import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
|
|
6
6
|
declare namespace ColumnResizingPlugin {
|
7
7
|
|
8
8
|
type Options = {
|
9
|
-
preserveProportion?: boolean,
|
10
|
-
preserveGridSize?: boolean,
|
11
|
-
noResizing?: boolean,
|
12
|
-
columnResized?: ((...params: any[]) => any),
|
13
|
-
dblClicked?: ((...params: any[]) => any),
|
14
|
-
dragStart?: ((...params: any[]) => any),
|
15
|
-
dragEnd?: ((...params: any[]) => any)
|
9
|
+
preserveProportion?: boolean|null,
|
10
|
+
preserveGridSize?: boolean|null,
|
11
|
+
noResizing?: boolean|null,
|
12
|
+
columnResized?: ((...params: any[]) => any)|null,
|
13
|
+
dblClicked?: ((...params: any[]) => any)|null,
|
14
|
+
dragStart?: ((...params: any[]) => any)|null,
|
15
|
+
dragEnd?: ((...params: any[]) => any)|null
|
16
16
|
};
|
17
17
|
|
18
18
|
type ColumnOptions = {
|
19
|
-
noResizing?: boolean,
|
20
|
-
defaultWidth?: number
|
19
|
+
noResizing?: boolean|null,
|
20
|
+
defaultWidth?: number|null
|
21
21
|
};
|
22
22
|
|
23
23
|
}
|
24
24
|
|
25
25
|
declare class ColumnResizingPlugin extends GridPlugin {
|
26
26
|
|
27
|
-
constructor(options?: ColumnResizingPlugin.Options);
|
27
|
+
constructor(options?: ColumnResizingPlugin.Options|null);
|
28
28
|
|
29
29
|
public getName(): string;
|
30
30
|
|
@@ -40,15 +40,15 @@ declare class ColumnResizingPlugin extends GridPlugin {
|
|
40
40
|
|
41
41
|
public getConfigObject(gridOptions?: any): any;
|
42
42
|
|
43
|
-
public disableResizing(colIndex: number, opt_disabled?: boolean): void;
|
43
|
+
public disableResizing(colIndex: number, opt_disabled?: boolean|null): void;
|
44
44
|
|
45
45
|
public getDraggedColumnIndex(): number;
|
46
46
|
|
47
47
|
public getDraggedAnchorX(): number;
|
48
48
|
|
49
|
-
public setColumnWidths(cols: (number)[], width: (number)[]|number, opt_scalable?: boolean): void;
|
49
|
+
public setColumnWidths(cols: (number)[]|null, width: (number)[]|number|null, opt_scalable?: boolean|null): void;
|
50
50
|
|
51
|
-
public setAllColumnWidths(colWidth: number, scalability?: boolean): boolean;
|
51
|
+
public setAllColumnWidths(colWidth: number, scalability?: boolean|null): boolean;
|
52
52
|
|
53
53
|
public getColumnWidths(): (number)[]|null;
|
54
54
|
|
@@ -56,11 +56,11 @@ declare class ColumnResizingPlugin extends GridPlugin {
|
|
56
56
|
|
57
57
|
public getColumnSizeStates(): (any)[]|null;
|
58
58
|
|
59
|
-
public setColumnSizeStates(columns: (any)[]|string): void;
|
59
|
+
public setColumnSizeStates(columns: (any)[]|string|null): void;
|
60
60
|
|
61
|
-
public enablePipeHandleMode(bool?: boolean): void;
|
61
|
+
public enablePipeHandleMode(bool?: boolean|null): void;
|
62
62
|
|
63
|
-
public enableHandlebarMode(bool?: boolean): void;
|
63
|
+
public enableHandlebarMode(bool?: boolean|null): void;
|
64
64
|
|
65
65
|
}
|
66
66
|
|