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

Retain scroll position on item delete / reset position on page change

2 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 06 Dec 2012, 10:51 PM
I have a grid where I would like to maintain the scroll position when an item in the grid is deleted, but I would like to reset the scroll position to the top when the page is changed.

I think it might be easier to set the SaveScrollPosition to true and reset the scroll on page change, but I am not sure how to implement this in the code behind.  I am using the "NeedDataSource" event to populate the grid.

Thanks.

-Angie

2 Answers, 1 is accepted

Sort by
0
Accepted
Kostadin
Telerik team
answered on 11 Dec 2012, 02:29 PM
Hi Angie,

A possible approach is to set SaveScrollPosition property to true OnPage_Load event handler and and set it to false when performing a paging.Check out the following code snippet.
protected void Page_Load(object sender, EventArgs e)
    {
        RadGrid1.ClientSettings.Scrolling.SaveScrollPosition = true;
    }
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.PageCommandName)
        {
            RadGrid1.ClientSettings.Scrolling.SaveScrollPosition = false;
        }
    }

Regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Angie
Top achievements
Rank 1
answered on 27 Dec 2012, 09:14 PM
Thanks Kostadin!  That worked perfectly!
Tags
Grid
Asked by
Angie
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Angie
Top achievements
Rank 1
Share this question
or