Grid auto-fitting columns moves the horizontal scroll

4 posts, 1 answers
  1. Materovich
    Materovich avatar
    9 posts
    Member since:
    Jul 2020

    Posted 22 Sep Link to this post

    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.

  2. Answer
    Martin
    Admin
    Martin avatar
    253 posts

    Posted 22 Sep Link to this post

    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).

  3. Materovich
    Materovich avatar
    9 posts
    Member since:
    Jul 2020

    Posted 24 Sep Link to this post

    Thank you Martin. That works great!
  4. Aliyyah
    Aliyyah avatar
    1 posts
    Member since:
    Nov 2020

    Posted 17 Nov Link to this post

    This happened for me also in the databound I put the line  e.sender.unbind('dataBound') before the autofit().
Back to Top