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

Scroll to pixel coord

2 Answers 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kristiyan
Top achievements
Rank 1
Kristiyan asked on 14 Jun 2019, 10:07 AM

Hello Telerik team, 

I have already checked older threads considering similar problems, but I still can't get it to work.

ngAfterViewInit(): void {
        this.scrollDiv = document.getElementsByClassName('k-virtual-content')[0];
        this.scrollDiv.addEventListener('scroll', this.onScroll);
    }
 
public onScroll($event: any) {
        this.scrollTop = $event.target.scrollTop;
    }

 

The problem arises when I scroll to some position, then change gridData so that I end up with another set of data entries with a different scrollTop position (e.g. empty with scrollTop 0) and when I come back to the initial data (change gridData again), then I end up having the initial skip value but scrollTop of 0 instead of my old value. 

So how can I utilize the scrollTop value? So far I have tried 

this.scrollDiv.scrollTop = this.scrollTop;

 

but I don't think this one can also act as a setter. Can I open a Feature Request for a grid method that does this?

 

Cheers and thanks in advance!

2 Answers, 1 is accepted

Sort by
0
Kristiyan
Top achievements
Rank 1
answered on 14 Jun 2019, 10:12 AM

 

Of course I meant

public onScroll($event: any) {
        this.scrollTop = $event.target.scrollTop;
        this.scrollDiv.scrollTop = this.scrollTop;
    }
0
Svet
Telerik team
answered on 18 Jun 2019, 10:34 AM
Hi Kristiyan,

The Grid scroll position is determined by internal logic based on the skip property of the Grid. This is why, changing the value of the skip property will change the position of the scrollbar respectively. Indeed, in order to achieve some custom scenario, the position of the scrollbar could also be changed by modifying the scrollTop property of the scrollable element, but this is not a built-in feature of Kendo UI for Angular. Could you provide some more relevant details about the specifics of the use case scenario, so that I can better understand it and try to suggest a solution. Thank you in advance.

Regards,
Svetlin
Progress Telerik
Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Kristiyan
Top achievements
Rank 1
Answers by
Kristiyan
Top achievements
Rank 1
Svet
Telerik team
Share this question
or