This is a migrated thread and some comments may be shown as answers.

Grid auto-fitting columns moves the horizontal scroll

3 Answers 1083 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Materovich
Top achievements
Rank 1
Veteran
Materovich asked on 22 Sep 2020, 10:57 AM

Hello,

I am using the autoFitColumns method on my grid and the column resize works perfect, but when I moved the horizontal scroll to the end and apply a filter on a column or a reorder, the grid refreshes and the scroll jumps to the left. This behaviour also ocur in your auto-fitting example: https://www.telerik.com/kendo-angular-ui/components/grid/columns/resizing/#toc-auto-fitting-the-content

I will like the grid mantains the scroll position after any refresh just like it use to happen without autofit.

Another alternative I explored is using the scrollTo method after call the autoFitColumns method. But I was unable to capture the last column visible after the refresh.

I will appreciate your help. Thanks.

3 Answers, 1 is accepted

Sort by
0
Accepted
Martin Bechev
Telerik team
answered on 22 Sep 2020, 02:10 PM

Hello Materovich,

Thank you for the provided link.

The demosntrated appraoch calls autoFitColumns method each time when dataStateChange event is emitted. However once the columns are reisized as per the method (e.g. in ngAfterViewInit hook) calling it on state change can be omitted:

https://stackblitz.com/edit/angular-mcphhl?file=app/app.component.ts

Another approach is to handle the filterChange (instead dataStateChange) event and to skip calling the the method only when fitlering is used.

In case of further questions do not hesitate to write back.

Regards,
Martin
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Materovich
Top achievements
Rank 1
Veteran
answered on 24 Sep 2020, 06:21 AM
Thank you Martin. That works great!
0
Aliyyah
Top achievements
Rank 1
answered on 18 Nov 2020, 01:44 AM
This happened for me also in the databound I put the line  e.sender.unbind('dataBound') before the autofit().
Tags
General Discussions
Asked by
Materovich
Top achievements
Rank 1
Veteran
Answers by
Martin Bechev
Telerik team
Materovich
Top achievements
Rank 1
Veteran
Aliyyah
Top achievements
Rank 1
Share this question
or