|
4 | 4 | AfterViewInit, |
5 | 5 | booleanAttribute, |
6 | 6 | ChangeDetectorRef, |
| 7 | + ComponentRef, |
7 | 8 | ContentChild, |
8 | 9 | ContentChildren, |
9 | 10 | createComponent, |
@@ -3121,6 +3122,7 @@ export abstract class IgxGridBaseDirective implements GridType, |
3121 | 3122 | protected _sortingOptions: ISortingOptions = { mode: 'multiple' }; |
3122 | 3123 | protected _filterStrategy: IFilteringStrategy = new FilteringStrategy(); |
3123 | 3124 | protected _autoGeneratedCols = []; |
| 3125 | + protected _autoGeneratedColsRefs: ComponentRef<IgxColumnComponent>[] = []; |
3124 | 3126 | protected _dataView = []; |
3125 | 3127 | protected _lastSearchInfo: ISearchInfo = { |
3126 | 3128 | searchText: '', |
@@ -3920,15 +3922,19 @@ export abstract class IgxGridBaseDirective implements GridType, |
3920 | 3922 | /** @hidden @internal */ |
3921 | 3923 | public setUpPaginator() { |
3922 | 3924 | if (this.paginator) { |
3923 | | - this.paginator.pageChange.pipe(takeWhile(() => !!this.paginator), filter(() => !this._init)) |
| 3925 | + this.paginator.pageChange |
| 3926 | + .pipe(takeWhile(() => !!this.paginator), filter(() => !this._init)) |
| 3927 | + .pipe(takeUntil(this.destroy$)) |
3924 | 3928 | .subscribe(() => { |
3925 | 3929 | this.selectionService.clear(true); |
3926 | 3930 | this.crudService.endEdit(false); |
3927 | 3931 | this.pipeTrigger++; |
3928 | 3932 | this.navigateTo(0); |
3929 | 3933 | this.notifyChanges(); |
3930 | 3934 | }); |
3931 | | - this.paginator.perPageChange.pipe(takeWhile(() => !!this.paginator), filter(() => !this._init)) |
| 3935 | + this.paginator.perPageChange |
| 3936 | + .pipe(takeWhile(() => !!this.paginator), filter(() => !this._init)) |
| 3937 | + .pipe(takeUntil(this.destroy$)) |
3932 | 3938 | .subscribe(() => { |
3933 | 3939 | this.selectionService.clear(true); |
3934 | 3940 | this.page = 0; |
@@ -3996,8 +4002,10 @@ export abstract class IgxGridBaseDirective implements GridType, |
3996 | 4002 | */ |
3997 | 4003 | public _zoneBegoneListeners() { |
3998 | 4004 | this.zone.runOutsideAngular(() => { |
3999 | | - this.verticalScrollContainer.getScroll().addEventListener('scroll', this.verticalScrollHandler.bind(this)); |
4000 | | - this.headerContainer?.getScroll().addEventListener('scroll', this.horizontalScrollHandler.bind(this)); |
| 4005 | + this.verticalScrollHandler = this.verticalScrollHandler.bind(this); |
| 4006 | + this.horizontalScrollHandler = this.horizontalScrollHandler.bind(this); |
| 4007 | + this.verticalScrollContainer.getScroll().addEventListener('scroll', this.verticalScrollHandler); |
| 4008 | + this.headerContainer?.getScroll().addEventListener('scroll', this.horizontalScrollHandler); |
4001 | 4009 | if (this.hasColumnsToAutosize) { |
4002 | 4010 | this.headerContainer?.dataChanged.pipe(takeUntil(this.destroy$)).subscribe(() => { |
4003 | 4011 | this.cdr.detectChanges(); |
@@ -4025,7 +4033,7 @@ export abstract class IgxGridBaseDirective implements GridType, |
4025 | 4033 | this._zoneBegoneListeners(); |
4026 | 4034 |
|
4027 | 4035 | const vertScrDC = this.verticalScrollContainer.displayContainer; |
4028 | | - vertScrDC.addEventListener('scroll', this.preventContainerScroll.bind(this)); |
| 4036 | + vertScrDC.addEventListener('scroll', this.preventContainerScroll); |
4029 | 4037 |
|
4030 | 4038 | this._pinnedRowList.changes |
4031 | 4039 | .pipe(takeUntil(this.destroy$)) |
@@ -4100,6 +4108,8 @@ export abstract class IgxGridBaseDirective implements GridType, |
4100 | 4108 | this.tmpOutlets.forEach((tmplOutlet) => { |
4101 | 4109 | tmplOutlet.cleanCache(); |
4102 | 4110 | }); |
| 4111 | + this._autoGeneratedColsRefs.forEach(ref => ref.destroy()); |
| 4112 | + this._autoGeneratedColsRefs = []; |
4103 | 4113 |
|
4104 | 4114 | this.destroy$.next(true); |
4105 | 4115 | this.destroy$.complete(); |
@@ -6106,7 +6116,7 @@ export abstract class IgxGridBaseDirective implements GridType, |
6106 | 6116 | this.configureRowEditingOverlay(id, this.rowList.length <= MIN_ROW_EDITING_COUNT_THRESHOLD); |
6107 | 6117 |
|
6108 | 6118 | this.rowEditingOverlay.open(this.rowEditSettings); |
6109 | | - this.rowEditingOverlay.element.addEventListener('wheel', this.rowEditingWheelHandler.bind(this)); |
| 6119 | + this.rowEditingOverlay.element.addEventListener('wheel', this.rowEditingWheelHandler); |
6110 | 6120 | } |
6111 | 6121 |
|
6112 | 6122 | /** |
@@ -6238,7 +6248,7 @@ export abstract class IgxGridBaseDirective implements GridType, |
6238 | 6248 | /** |
6239 | 6249 | * @hidden |
6240 | 6250 | */ |
6241 | | - public rowEditingWheelHandler(event: WheelEvent) { |
| 6251 | + public rowEditingWheelHandler = (event: WheelEvent) => { |
6242 | 6252 | if (event.deltaY > 0) { |
6243 | 6253 | this.verticalScrollContainer.scrollNext(); |
6244 | 6254 | } else { |
@@ -7089,11 +7099,14 @@ export abstract class IgxGridBaseDirective implements GridType, |
7089 | 7099 | const fields = this.generateDataFields(data); |
7090 | 7100 | const columns = []; |
7091 | 7101 |
|
| 7102 | + this._autoGeneratedColsRefs.forEach(ref => ref.destroy()); |
| 7103 | + this._autoGeneratedColsRefs = []; |
7092 | 7104 | fields.forEach((field) => { |
7093 | 7105 | const ref = createComponent(IgxColumnComponent, { environmentInjector: this.envInjector, elementInjector: this.injector }); |
7094 | 7106 | ref.instance.field = field; |
7095 | 7107 | ref.instance.dataType = this.resolveDataTypes(data[0][field]); |
7096 | 7108 | ref.changeDetectorRef.detectChanges(); |
| 7109 | + this._autoGeneratedColsRefs.push(ref); |
7097 | 7110 | columns.push(ref.instance); |
7098 | 7111 | }); |
7099 | 7112 | this._autoGeneratedCols = columns; |
@@ -7401,7 +7414,7 @@ export abstract class IgxGridBaseDirective implements GridType, |
7401 | 7414 | } |
7402 | 7415 |
|
7403 | 7416 | if (delayScrolling) { |
7404 | | - this.verticalScrollContainer.dataChanged.pipe(first()).subscribe(() => { |
| 7417 | + this.verticalScrollContainer.dataChanged.pipe(first(), takeUntil(this.destroy$)).subscribe(() => { |
7405 | 7418 | this.scrollDirective(this.verticalScrollContainer, |
7406 | 7419 | typeof (row) === 'number' ? row : this.unpinnedDataView.indexOf(row)); |
7407 | 7420 | }); |
@@ -7555,7 +7568,7 @@ export abstract class IgxGridBaseDirective implements GridType, |
7555 | 7568 | let row = this.summariesRowList.filter(s => s.index !== 0).concat(this.rowList.toArray()).find(r => r.index === rowIndex); |
7556 | 7569 | if (!row) { |
7557 | 7570 | if ((this as any).totalItemCount) { |
7558 | | - this.verticalScrollContainer.dataChanged.pipe(first()).subscribe(() => { |
| 7571 | + this.verticalScrollContainer.dataChanged.pipe(first(), takeUntil(this.destroy$)).subscribe(() => { |
7559 | 7572 | this.cdr.detectChanges(); |
7560 | 7573 | row = this.summariesRowList.filter(s => s.index !== 0).concat(this.rowList.toArray()).find(r => r.index === rowIndex); |
7561 | 7574 | const cbArgs = this.getNavigationArguments(row, visibleColIndex); |
|
0 commit comments