Getting Scroll Position of RadGrid on Edit

4 posts, 0 answers
  1. Cheyne
    Cheyne avatar
    3 posts
    Member since:
    Aug 2012

    Posted 04 Aug Link to this post

    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

  2. Cheyne
    Cheyne avatar
    3 posts
    Member since:
    Aug 2012

    Posted 05 Aug in reply to Cheyne Link to this post

    Any one from the Telerik team able to help me ?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Cheyne
    Cheyne avatar
    3 posts
    Member since:
    Aug 2012

    Posted 05 Aug in reply to Cheyne Link to this post

    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

  5. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 09 Aug Link to this post

    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.
Back to Top