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

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

4 Answers 109 Views
GridView
This is a migrated thread and some comments may be shown as answers.
minh
Top achievements
Rank 2
Iron
Iron
Iron
minh asked on 22 Jan 2021, 07:48 AM

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!

 

4 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 26 Jan 2021, 04:21 PM

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/.

0
minh
Top achievements
Rank 2
Iron
Iron
Iron
answered on 27 Jan 2021, 03:07 AM

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,

0
Accepted
Dilyan Traykov
Telerik team
answered on 29 Jan 2021, 03:01 PM

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/.

0
minh
Top achievements
Rank 2
Iron
Iron
Iron
answered on 18 Mar 2021, 04:34 AM
Many thanks. It solved my problem
Tags
GridView
Asked by
minh
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dilyan Traykov
Telerik team
minh
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or