Skip to content

fix(grid): Setup columns when autoGenerate is set after the grid data - #17227

Open
mddragnev wants to merge 8 commits into
masterfrom
mdragnev/fix-16830-master
Open

fix(grid): Setup columns when autoGenerate is set after the grid data#17227
mddragnev wants to merge 8 commits into
masterfrom
mdragnev/fix-16830-master

Conversation

@mddragnev

Copy link
Copy Markdown
Member

Closes #16830

Type of Change (check all that apply):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

How Has This Been Tested?

  • Unit tests
  • Manual testing
  • Automated e2e tests

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

@mddragnev mddragnev added the ❌ status: awaiting-test PRs awaiting manual verification label Apr 23, 2026
Copilot AI review requested due to automatic review settings April 23, 2026 06:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ngOnChanges handling in IgxGridBaseDirective to call setupColumns() when autoGenerate is 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 ngOnChanges now overrides a base implementation (IgxGridBaseDirective.ngOnChanges). Since it doesn’t call super.ngOnChanges(changes), any base change-handling (including the new autoGenerate handling) will be skipped for the pivot grid. Consider calling super.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 ngOnChanges now overrides a base implementation (IgxGridBaseDirective.ngOnChanges). Since it doesn’t call super.ngOnChanges(changes), any base change-handling (including the new autoGenerate handling) will be skipped for IgxRowIslandComponent. Consider calling super.ngOnChanges(changes) before emitting layoutChange so base behavior is preserved.
    public override ngOnChanges(changes) {
        this.layoutChange.emit(changes);
        if (!this.isInit) {
            this.initialChanges.push(changes);
        }

Comment thread projects/igniteui-angular/grids/grid/src/grid-base.directive.ts
@github-actions

Copy link
Copy Markdown

There has been no recent activity and this PR has been marked inactive.

@github-actions github-actions Bot added the status: inactive Used to stale issues and pull requests label Jun 23, 2026
@kdinev kdinev removed the status: inactive Used to stale issues and pull requests label Jun 23, 2026
@dkamburov

Copy link
Copy Markdown
Contributor

@mddragnev please resolve the conflict

kdinev
kdinev previously approved these changes Jun 23, 2026
@MayaKirova MayaKirova added ✅ status: verified Applies to PRs that have passed manual verification and removed ❌ status: awaiting-test PRs awaiting manual verification labels Jul 24, 2026
Copilot AI review requested due to automatic review settings July 30, 2026 08:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • IgxPivotGridComponent overrides ngOnChanges() but does not call super.ngOnChanges(). Since IgxGridBaseDirective now implements ngOnChanges() (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

  • IgxRowIslandComponent overrides ngOnChanges() but does not call super.ngOnChanges(). Since IgxGridBaseDirective now implements ngOnChanges() (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.changes subscription was moved out of setupColumns() into IgxGridBaseDirective.ngAfterContentInit(). Subclasses that override ngAfterContentInit() without calling super.ngAfterContentInit() (e.g. IgxPivotGridComponent at pivot-grid.component.ts:989 and IgxRowIslandComponent at row-island.component.ts:365) will no longer call onColumnsChanged(). Previously they still got the subscription because they call setupColumns(), but setupColumns() no longer wires it. This can regress pivot grid/hierarchical behavior when columns change (e.g. Ivy re-evaluation case handled in onColumnsChanged).
        this.setupColumns();
        this.columnList.changes
            .pipe(takeUntil(this.destroy$))
            .subscribe((change: QueryList<IgxColumnComponent>) => {
                this.onColumnsChanged(change);
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

grid ✅ status: verified Applies to PRs that have passed manual verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grids: Setting grid data before autoGenerate of columns after the component is initialized does not render any data

6 participants