autoFitColumns does not consider rows outside current virtual page when using virtual scrolling

1 Answer 11 Views
Grid
CARLOS
Top achievements
Rank 1
CARLOS asked on 20 Aug 2025, 04:00 PM

Hi,

I'm using kendo-grid in Angular with both resizable columns and virtual scrolling enabled.
I also call the autoFitColumns() method (through ViewChild) to auto-adjust the column widths based on the content.

However, I noticed the following problematic behavior:

  • My grid uses pageSize = 60, so only 60 rows are rendered in the DOM at a time.

  • I have a total of about 101 rows.

  • The content in row #101 is much wider than any of the rows currently rendered.

  • When I call autoFitColumns(), the method calculates the width based only on the visible (rendered) rows (the first 60).

  • As a result, when I scroll down to row 101, the cell shows ellipsis (...) because the column width didn't get adjusted based on its content.

It seems that autoFitColumns() does not take into account rows that aren't currently rendered due to virtual scrolling.


Expected behavior:
Ideally, autoFitColumns() should consider the ENTIRE dataset, or at least provide an option to temporarily render all rows, so the width is calculated correctly.


I'll attach a sample StackBlitz with:

  • 101 records

  • Virtual scrolling + resizable = true

  • Last row has a long text

  • After calling autoFitColumns, the column is not wide enough and shows "..."

Could you please confirm if this is expected behavior or if there's a recommended workaround?

https://stackblitz.com/edit/angular-8rzs1wr6-7hvlbi8f?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fproducts.ts

Thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Martin Bechev
Telerik team
answered on 25 Aug 2025, 09:02 AM

Hi Carlos,

To auto-size the column width for the new portion of data, handle the pageChange event, and resize the column with the autoFitColumns() method again:

https://stackblitz.com/edit/angular-8rzs1wr6-mf9iaxtl

This is necessary because, at the time of applying the method, we don't have information about the rest of the data (due to the virtual scrolling feature). That is why when the next data is loaded, we need to resize the columns again.

I hope this sheds some light on the case

Regards,
Martin Bechev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
CARLOS
Top achievements
Rank 1
Answers by
Martin Bechev
Telerik team
Share this question
or