fix(grid): Setup columns when autoGenerate is set after the grid data#17004
Open
fix(grid): Setup columns when autoGenerate is set after the grid data#17004
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an issue where grids fail to render data when data is assigned first and autoGenerate is enabled afterward, by ensuring columns are generated in that sequence.
Changes:
- Add
IgxGridBaseDirective.ngOnChangeshandling forautoGeneratetoggled after data is already present. - Ensure
autoGenerateinput triggers change handling via@WatchChanges(), and adjustWatchChangesinitialization guard. - Add a unit test covering the “set data first, then set autoGenerate” 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/grid/src/grid-base.directive.ts | Adds OnChanges support and generates columns when autoGenerate becomes true after data is set; adjusts column change subscription placement. |
| projects/igniteui-angular/grids/core/src/watch-changes.ts | Tightens initialization check before manually invoking ngOnChanges from the decorator. |
| projects/igniteui-angular/grids/grid/src/grid.component.spec.ts | Adds regression test for setting autoGenerate after data. |
| projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts | Marks ngOnChanges as override after base introduces ngOnChanges. |
| projects/igniteui-angular/grids/hierarchical-grid/src/row-island.component.ts | Marks ngOnChanges as override after base introduces ngOnChanges. |
Comments suppressed due to low confidence (2)
projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts:1027
IgxPivotGridComponentoverridesngOnChangesbut does not callsuper.ngOnChanges(changes). SinceIgxGridBaseDirectivenow implementsngOnChanges(and contains the autoGenerate fix), the base behavior will be skipped for pivot grids. Consider callingsuper.ngOnChanges(changes)(typically first) unless intentionally opting out of the base handling.
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:479
IgxRowIslandComponentoverridesngOnChangesbut does not callsuper.ngOnChanges(changes). With the newIgxGridBaseDirective.ngOnChangesimplementation, this will bypass base input-change handling (including the new autoGenerate behavior) for row islands. Callsuper.ngOnChanges(changes)unless you explicitly want to suppress the base logic.
public override ngOnChanges(changes) {
this.layoutChange.emit(changes);
if (!this.isInit) {
this.initialChanges.push(changes);
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16830
Additional information (check all that apply):
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)