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

[Solved] Reset scrollbar to top

6 Answers 300 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Teodorico
Top achievements
Rank 1
Teodorico asked on 17 Jul 2009, 01:15 AM

Hi,

I have a grid pagination and I am displaying 25 items per page. If the user scrolls down and moves to the next/previous page, how can I reposition the scrollbar so the first item in the table gets visible? Should the grid do this automatically?

 
<div style="width:100%;height:100%">  
    <telerik:RadGrid  
        ID="RadGrid" 
        runat="server" 
        AllowPaging="true" 
        PageSize="25" 
        Width="100%" 
        Height="100%" 
        style="border:0px;outline:none" 
        > 
        <MasterTableView TableLayout="Auto" ClientDataKeyNames="Id, Icon, IsPrivate">  
            <Columns> 
                <telerik:GridBoundColumn DataField="Icon" HeaderText="" HtmlEncode="false" HeaderStyle-Width="26px"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Name" HeaderText="Food" HtmlEncode="false" HeaderStyle-Width="100%"></telerik:GridBoundColumn> 
            </Columns> 
        </MasterTableView> 
        <ClientSettings EnableRowHoverStyle="true">  
            <Selecting AllowRowSelect="true" /> 
            <Scrolling AllowScroll="true" UseStaticHeaders="true" /> 
            <DataBinding Location="Grid.aspx" SelectMethod="Search" FilterParameterType="String" SortParameterType="String"></DataBinding> 
            <ClientEvents OnDataBinding="RadGrid_DataBinding" OnRowClick="RadGrid_RowClick" OnRowDblClick="RadGrid_RowDblClick" OnDataBound="RadGrid_DataBound" /> 
        </ClientSettings> 
        <PagerStyle Mode="Slider" /> 
    </telerik:RadGrid> 
</div> 
 


Thanks.

 

 

6 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 17 Jul 2009, 12:15 PM
Hello Teodorico,

Please refer to the following help article:

http://www.telerik.com/help/aspnet-ajax/ajxpanelscrolltotop.html

Best wishes,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Teodorico
Top achievements
Rank 1
answered on 17 Jul 2009, 12:30 PM
Dimo,
Thanks for the link, but I need to reset to the top the scrollbar within the RadGrid not the page Window. I have looked at the API but no luck.

Thanks.
0
Dimo
Telerik team
answered on 17 Jul 2009, 12:53 PM
Hello Teodorico,

In this case you have to specify a different value for the scrollTop property, not zero. You can use the ASP.NET AJAX client library method getLocation or $telerik.getLocation() (the latter works in exactly the same fashion, but better) in order to find out the vertical position of the RadGrid outer DOM element:

var grid_instance = $find("<%= RadGrid1.ClientID %>");
var grid_dom_element = grid_instance.get_element();

or

var grid_dom_element = $get("<%= RadGrid1.ClientID %>");


Regards,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Teodorico
Top achievements
Rank 1
answered on 22 Jul 2009, 12:37 AM

Dimo,
I could not follow your instructions but I tried the following which works but I would like to know if it safe to do.

function RadGrid_DataBound()  
{  
    var gridDomElement = $get("RadGrid_GridData");  
    gridDomElement.scrollTop = 0;  
}  
 

I am referencing directly the div within the grid (x_GridData).

Thanks.

I am referencing directly the div within the grid (x_GridData).Thanks.
0
Dimo
Telerik team
answered on 22 Jul 2009, 10:14 AM
Hi Teodorico,

It seems that I have misunderstood your previous post, sorry about that.

Your approach is correct, however, a better one is to use

<Scrolling SaveScrollPosition="false" />


All the best,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Teodorico
Top achievements
Rank 1
answered on 22 Jul 2009, 11:22 PM
Dimo,
For some reason it is not working, but no worries, I'll keep using scrollTop = 0.

Thanks.
Tags
Grid
Asked by
Teodorico
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Teodorico
Top achievements
Rank 1
Share this question
or