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

Getting Scroll Position of RadGrid on Edit

3 Answers 303 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cheyne
Top achievements
Rank 1
Cheyne asked on 04 Aug 2016, 09:48 AM

Hi,

 

I have a radgrid with scrolling enabled and static headers. Everything works perfect. However, the issue im faced with is when I click edit, I need to scroll down to get to the edit portion and after saving or cancelling, the scroll position is saved on the LAST scroll position, which means that the scroll position will now be way lower than it was when I clicked edit. I hope this makes sense.

 

All I want to do, is save the scroll position when I clicked edit, so that once updated or cancelled, that it will go back to that scroll position. 

 

Please could you help ?

 

Thank you

3 Answers, 1 is accepted

Sort by
0
Cheyne
Top achievements
Rank 1
answered on 05 Aug 2016, 10:27 AM
Any one from the Telerik team able to help me ?
0
Cheyne
Top achievements
Rank 1
answered on 05 Aug 2016, 11:19 AM

I found the solution myself.

On the EditCommand of the RadGrid, I retrieved the value for ScrollTop and saved it into a HiddenField :

 

 Protected Sub rGVDELTaskLog_EditCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles rGVDELTaskLog.EditCommand
        Dim ScrollPosition As Integer

        If TypeOf e.Item Is GridDataItem Then
            If rGVDELTaskLog.ClientSettings.Scrolling.ScrollTop = "" Then
                ScrollPosition = 0
            Else
                ScrollPosition = rGVDELTaskLog.ClientSettings.Scrolling.ScrollTop
            End If

            hidScrollPosition.Value = ScrollPosition

        End If
    End Sub

 

I then Set the ScrollTop of the RadGrid to the value in the HiddenField on say for example on the CancelCommand(The same would go for the UpdateCommand) :

 

    Protected Sub rGVDELTaskLog_CancelCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles rGVDELTaskLog.CancelCommand
        rGVDELTaskLog.ClientSettings.Scrolling.ScrollTop = hidScrollPosition.Value
    End Sub

0
Eyup
Telerik team
answered on 09 Aug 2016, 07:40 AM
Hi Cheyne,

Thank you for sharing your approach with our community. This can be also achieved using client-side approach as similar to the demonstrated implementation in the attached web site sample.

Regards,
Eyup
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Cheyne
Top achievements
Rank 1
Answers by
Cheyne
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or