when scrollbar position is at the bottom, the 1st row in the view disappears on reloading the RadGridView

0 Answers 107 Views
GridView
dharmesh
Top achievements
Rank 1
dharmesh asked on 12 Nov 2021, 08:19 AM | edited on 12 Nov 2021, 08:20 AM

Implemented the behavior to adjust the scroll position so that the selected item will appear on the top in the view.

code for above behavior:
                        var scrollOffset = gridView.Items.IndexOf(SelectedItem) * gridView.RowHeight;

                        //get the scrollviewer control
                        var scrollViewer = gridView.ChildrenOfType<Telerik.Windows.Controls.GridView.GridViewScrollViewer>                                                                     ().First();

                        // scrollbar position
                        var verticalOffset = scrollViewer.VerticalOffset;
                        var viewportHeight = scrollViewer.ViewportHeight;

                        if (scrollOffset > verticalOffset || scrollOffset > (verticalOffset + viewportHeight))
                        {
                            scrollViewer.ScrollToVerticalOffset(scrollOffset);
                        }

 

11 items are there in the view. If 3rd last item is selected.
Steps performed to reproduce the issue:
1. Scrolled down to the bottom.
2. restarted the application and opened the view which contains radgridview.
3. above code for scroll item to top executed on the loading of radgridview.
4. please refer the attached image which shows issue.

Disappeared row appears again on scrolling the radgridview.

If Virtualization row is turned off, this issue does not reproduce but it kills the performance.

Need to get another solution for this issue.

Martin Ivanov
Telerik team
commented on 16 Nov 2021, 01:42 PM

Can you set the GroupRenderMode property of RadGridView to Flat and see if the issue still persist? If so, I would recommend you to send over a sample project reproducing the issue.
dharmesh
Top achievements
Rank 1
commented on 17 Nov 2021, 08:53 AM

After setting  GroupRenderMode=Flat the issue is not reproducible now. 
Thanks for the solution.
dharmesh
Top achievements
Rank 1
commented on 26 Nov 2021, 09:55 AM

After setting  GroupRenderMode=Flat, above mentioned issue is fixed but the behavior to adjust the scroll position so that the selected item will appear on the top in the view is not working on sorting. 
I have share code snippet in above question.
Martin Ivanov
Telerik team
commented on 30 Nov 2021, 10:19 AM

Can you tell me when do you execute the above mentioned code? I mean what event or on what action do you call the logic?

In the meantime, you can try to save the VerticalOffset of the ScrollViewer when the Sorting event is fired and then restore it on Sorted.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
dharmesh
Top achievements
Rank 1
Share this question
or