horizontal scroll resets in angular kendo grid when using autofitcolumns on a dynamic content grid

0 Answers 2 Views
Grid
Aaron
Top achievements
Rank 1
Aaron asked on 04 Nov 2025, 11:47 AM

I'm rendering a kendo-grid that receives data dynamically in runtime and required to autofit the columns continuously as data arrives.

I've used autoFitColumns() on the ngAfterViewChecked lifecycle hook to keep autofitting with each new data arrival. but each autofit resets the view of the grid and the horizontal scroll is reset to the start.

I searched for other issues regarding the subjects but none worked for this scenario.
tried solutions:

  1. using ngZone and subscribing to OnStable
  2. saving the scrollLeft property of '.k-grid-content' and and assigning the value to it after the autoFitColumns() call
  3. calling autoFitColumns on specific changes within ngOnChanges.


without autofit there are no issues despite many dynamic data changes.

template parameters:

<kendo-grid
#grid
[kendoGridBinding]="gridData"
[skip]="skip"
[resizeable]="true"
....>

component (simplified)


export class Component {
@Input() columns$: Observable<TableColumns[]>
@Input gridData: any[];
@ViewChild(GridComponent) grid: GridComponent;

ngOnInit(){
this.columns$?.pipe(filter((cols)=> !!cols && cols.length > 0)).subscribe......
}

ngAfterViewChecked() {
this.grid?.autoFitColumns();
}

Help is appreciated.

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Aaron
Top achievements
Rank 1
Share this question
or