RadGridView with grouping headers: Page-Up, Page-Down key controls does an incorrect vertical scroll height

5 posts, 1 answers
  1. minh
    minh avatar
    8 posts
    Member since:
    Feb 2015

    Posted 22 Jan Link to this post

    Dear Telerik support team,

    I have a RadGridView with more than 1 groups headers. When I use Page-Up, Page-Down key control to navigate inside the grid, the scroll height doesn't take in account the height of grouping headers. So that, while pressed on PageDown, the scroll goes to the middle of the next "page".

    I attached a scenario as below:

    1. When I'm in the first row of grid (see image: Before_PageDown.png), if I put on "Page Down" key, I expect the selection cursor goes to line "10916" (the last line of my viewport).

    2. However, in reality, when I pressed on Page Down, it goes to line "10353" (see image: After_PageDown.png),

     

    Many thanks for your help!

     

  2. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    1258 posts

    Posted 26 Jan Link to this post

    Hello,

    Thank you for the provided images.

    The behavior you described is expected as indeed, the RadGridView control takes into account the number of items that can be held in the viewport and moves the current item based on this value.

    If you want to disregard the number of items and scroll the whole height of the viewport, you can create a custom KeyboardCommandProvider and override this default logic.

    For your convenience, I've prepared a small sample project which demonstrates this approach. Please have a look and let me know if this would work for you.

    Regards,
    Dilyan Traykov
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

  3. minh
    minh avatar
    8 posts
    Member since:
    Feb 2015

    Posted 26 Jan in reply to Dilyan Traykov Link to this post

    Hi Dilyan,

    Many thanks for your very useful help.

    The scroll works for me.

    However, I also need select a nearest row where the scroll goes to. Do you have any idea how to realize that?

     

    Many thanks,

  4. Answer
    Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    1258 posts

    Posted 29 Jan Link to this post

    Hello,

    You will need to calculate the index of the new item based on the number of rows in the viewport. Here's an example of how you can achieve this:

                if (key == Key.PageDown || key == Key.PageUp)
                {
                    commandsToExecute.Clear();
                    var scrollViewer = this.parentGrid.ChildrenOfType<GridViewScrollViewer>().First();
                    var height = scrollViewer.ViewportHeight;
                    var coef = key == Key.PageDown ? 1 : -1;
                    scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset + (height * coef));
                    int rowCount = (int)(height / this.parentGrid.RowHeight);
                    var groupRows = this.parentGrid.ChildrenOfType<GroupHeaderRow>().Where(r => r.ActualHeight > 0).Count();
                    var currentIndex = this.parentGrid.Items.IndexOf(this.parentGrid.CurrentItem);
                    var newItem = this.parentGrid.Items[currentIndex + rowCount - groupRows];
                    this.parentGrid.CurrentItem = newItem;
                }
    Of course, you can further tune this to behave exactly as you want. I do hope you find this helpful.

    Regards,
    Dilyan Traykov
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

  5. minh
    minh avatar
    8 posts
    Member since:
    Feb 2015

    Posted 17 Mar in reply to Dilyan Traykov Link to this post

    Many thanks. It solved my problem
Back to Top