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

How to SaveScrollPosition and Scroll To Top of RadGrid

1 Answer 864 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 27 Jan 2012, 11:08 PM

We have the following RadGrid

<telerik:RadGrid
    ID="RadGrid1"
    runat="server"
    Visible="true"
    Width="1260px"
    Height="445px"
    AutoGenerateColumns="False"
    CssClass="RadGridCustomClass"
    CellSpacing="0"
    GridLines="None"
    OnPageIndexChanged="RadGrid1_PageIndexChanged"
    OnColumnCreated="RadGrid1_ColumnCreated"
    OnItemDataBound="RadGrid1_ItemDataBound"
    OnDetailTableDataBind="RadGrid1_DetailTableDataBind"
    OnPageSizeChanged="RadGrid1_OnPageSizeChanged"
    OnSortCommand="RadGrid1_SortCommand"
    OnItemCommand="RadGrid1_ItemCommand"
    OnPreRender="RadGrid1_PreRender"
    BorderStyle="None">
    <ClientSettings>
        <Scrolling AllowScroll="True"
            UseStaticHeaders="True" 
            SaveScrollPosition="True" 
            EnableVirtualScrollPaging="False" />
    </ClientSettings>
    <MasterTableView
        AutoGenerateColumns="false"
        DataKeyNames="Emplid"
        AllowPaging="true"
        AllowSorting="True"
        PageSize="50"
        TableLayout="Fixed"
        Width="1410px"
        CommandItemDisplay="Top"
        HierarchyLoadMode="ServerOnDemand"
        PagerStyle-Mode="NextPrevNumericAndAdvanced"
        PagerStyle-AlwaysVisible="True"
        AllowFilteringByColumn="False"
        AllowMultiColumnSorting="False"
        ExpandCollapseColumn-Visible="False"
        CommandItemSettings-ShowExportToWordButton="False"
        PagerStyle-Position="Bottom"
        PagerStyle-PageSizeLabelText="Page Size:"
        CommandItemStyle-Wrap="True">
        <DetailTables>

 

We also use ajax when expanding DetailsTable and paging.

The user scrolls down and expands a row and the scroll position is saved.
Then the user goes to the next page of the grid and the position is still saved. We would like the grid content to scroll to the top of the grid. Why is there not a built in way of doing this? Why not just add a to the control ScrollToTopOfGridOnPaging="True".

In lieu of this, how do we accomplish this task?

Edit: It does not matter if we do this on the server side or the client side.
Edit 2: updated post.

1 Answer, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 2
answered on 30 Jan 2012, 05:08 PM
I found a solution to the problem.
1. We have set the SaveScrollPosition to true
2. In RadGrid1_PageIndexChanged, add
RadGrid1.ClientSettings.Scrolling.ScrollTop = "0";

Now when we update a value in the grid somewhere in the middle, the grid stays at the location after a submit and if we page to another section of the grid it set the focus to the top of the grid.
Tags
Grid
Asked by
Michael
Top achievements
Rank 2
Answers by
Michael
Top achievements
Rank 2
Share this question
or