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

How to scroll to top of RadListBox

1 Answer 310 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 05 Dec 2019, 02:30 AM

Hello Telerik,

I have created a sample project with a RadListBox and a button.

When the page loads, the list is populated using some query from the Northwind database.

After scrolling the list at a random item, and pressing the button to reload the list,

I would like to position the list at the top, not at an arbitrary place in the list.

This functionality should not depend if I have and item selected or not in the list.

Thanks,

Alex

1 Answer, 1 is accepted

Sort by
0
Accepted
Peter Milchev
Telerik team
answered on 10 Dec 2019, 11:08 AM

Hello Alex,

For convenience and better visibility from the community, I am sharing the solution from the official support thread here.

The RadListBox has scroll persistence which saves the scroll position and restores it before the control is loaded fully on the client-side. 

Nevertheless, you can set the scrollTop property of the _groupElement to 0 and always have the RadListBox scrolled to the top on page load:

<telerik:RadListBox ID="Item1ListBox" runat="server"
			        Height="200px" Width="200px"
			        RenderMode="Lightweight"
    OnClientLoad="OnClientLoad"
			        SelectionMode="Single"
			        Skin="MetroTouch"
			        ViewStateMode="Enabled">
</telerik:RadListBox>
<script>
    function OnClientLoad(sender, args) {
        sender._groupElement.scrollTop = 0;
    }
</script>

Regards,
Peter Milchev
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ListBox
Asked by
Alex
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or