fix(grid): Setup columns when autoGenerate is set after the grid data - #17227
fix(grid): Setup columns when autoGenerate is set after the grid data#17227mddragnev wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a grid rendering issue where setting data first and then enabling autoGenerate after initialization results in no data being rendered (issue #16830).
Changes:
- Adds
ngOnChangeshandling inIgxGridBaseDirectiveto callsetupColumns()whenautoGenerateis enabled after data is already present. - Adjusts some derived grid components to explicitly
override ngOnChanges. - Adds a unit test covering the “data first, autoGenerate later” scenario.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts | Marks ngOnChanges as override in pivot grid. |
| projects/igniteui-angular/grids/hierarchical-grid/src/row-island.component.ts | Marks ngOnChanges as override in row island. |
| projects/igniteui-angular/grids/grid/src/grid.component.spec.ts | Adds a unit test for toggling autoGenerate after setting data. |
| projects/igniteui-angular/grids/grid/src/grid-base.directive.ts | Implements OnChanges, wires autoGenerate via @WatchChanges, and triggers setupColumns() on relevant changes. |
| projects/igniteui-angular/grids/core/src/watch-changes.ts | Tweaks WatchChanges to avoid calling ngOnChanges when _init is undefined. |
Comments suppressed due to low confidence (2)
projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts:1028
- This
ngOnChangesnow overrides a base implementation (IgxGridBaseDirective.ngOnChanges). Since it doesn’t callsuper.ngOnChanges(changes), any base change-handling (including the newautoGeneratehandling) will be skipped for the pivot grid. Consider callingsuper.ngOnChanges(changes)to preserve base behavior and future-proof overrides.
public override ngOnChanges(changes: SimpleChanges) {
if (changes.superCompactMode && !changes.superCompactMode.isFirstChange()) {
this._shouldUpdateSizes = true;
resizeObservable(this.verticalScrollContainer.displayContainer).pipe(take(1), takeUntil(this.destroy$)).subscribe(() => this.resizeNotify.next());
}
}
projects/igniteui-angular/grids/hierarchical-grid/src/row-island.component.ts:475
- This
ngOnChangesnow overrides a base implementation (IgxGridBaseDirective.ngOnChanges). Since it doesn’t callsuper.ngOnChanges(changes), any base change-handling (including the newautoGeneratehandling) will be skipped forIgxRowIslandComponent. Consider callingsuper.ngOnChanges(changes)before emittinglayoutChangeso base behavior is preserved.
public override ngOnChanges(changes) {
this.layoutChange.emit(changes);
if (!this.isInit) {
this.initialChanges.push(changes);
}
|
There has been no recent activity and this PR has been marked inactive. |
|
@mddragnev please resolve the conflict |
…into mdragnev/fix-16830-master
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts:1030
IgxPivotGridComponentoverridesngOnChanges()but does not callsuper.ngOnChanges(). SinceIgxGridBaseDirectivenow implementsngOnChanges()(autoGenerate handling), skipping the base implementation can prevent base change-handling from running for pivot grid when relevant inputs change.
public override ngOnChanges(changes: SimpleChanges) {
if (changes.superCompactMode && !changes.superCompactMode.isFirstChange()) {
this._shouldUpdateSizes = true;
resizeObservable(this.verticalScrollContainer.displayContainer).pipe(take(1), takeUntil(this.destroy$)).subscribe(() => this.resizeNotify.next());
}
}
projects/igniteui-angular/grids/hierarchical-grid/src/row-island.component.ts:440
IgxRowIslandComponentoverridesngOnChanges()but does not callsuper.ngOnChanges(). SinceIgxGridBaseDirectivenow implementsngOnChanges()(autoGenerate handling), calling the base implementation avoids accidentally skipping base change-handling if a relevant inherited input changes in the future.
public override ngOnChanges(changes) {
this.layoutChange.emit(changes);
if (!this.isInit) {
this.initialChanges.push(changes);
}
}
projects/igniteui-angular/grids/grid/src/grid-base.directive.ts:4024
columnList.changessubscription was moved out ofsetupColumns()intoIgxGridBaseDirective.ngAfterContentInit(). Subclasses that overridengAfterContentInit()without callingsuper.ngAfterContentInit()(e.g.IgxPivotGridComponentatpivot-grid.component.ts:989andIgxRowIslandComponentatrow-island.component.ts:365) will no longer callonColumnsChanged(). Previously they still got the subscription because they callsetupColumns(), butsetupColumns()no longer wires it. This can regress pivot grid/hierarchical behavior when columns change (e.g. Ivy re-evaluation case handled inonColumnsChanged).
this.setupColumns();
this.columnList.changes
.pipe(takeUntil(this.destroy$))
.subscribe((change: QueryList<IgxColumnComponent>) => {
this.onColumnsChanged(change);
});
Closes #16830
Type of Change (check all that apply):
How Has This Been Tested?
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)