GridView ScrollBar EndUpdate() want Stop ScrollToBegin

2 Answers 64 Views
GridView ScrollBar
Park
Top achievements
Rank 1
Iron
Park asked on 30 May 2024, 09:07 AM | edited on 30 May 2024, 09:07 AM

Hi!

When endUpdate occurs in gridview, the scroll moves to the begin.

In my environment I have to beginUpdate and Endupdate.

But 1 dont' want the scroll to move even if the data is Updated(endupdate timing)!

Please tell me how to prevent the scroll from moving automatically when editing mode is released by double-clicking or when endupdate occurs.

The method of updating the scroll value after endupdate by storing the scroll value before beginupdate failed.

A gif Image and simple project are attached. Please help me!!!

Thank you :)

 

 

2 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 04 Jun 2024, 06:35 AM

Hello, Park,

Thank you for writing.

Indeed, storing the TableElement.VScrollBar.Value property will allow you to preserve the current position of the vertical scrollbar and then restore it after the update. I can see that you are trying to achieve something similar in your project. However, please have in mind that depending on the number of rows that RadGridView has, the scrollbar's range gets updated accordingly.

In your case when there is a hierarchy as well a possible solution is to keep the expanded state of the rows along with the vertical scrollbar. A sample approach is demonstrated in this forum thread: Rad Grid view position after reload of the data in UI for WinForms | Telerik Forums

I hope this information is useful. If you have any other questions do not hesitate to ask.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Park
Top achievements
Rank 1
Iron
commented on 11 Jun 2024, 05:14 AM | edited

Hello! Nadya~!

 

Thank you so much for answering in advance.

However, the Rad Grid view position after reload of the data in UI for WinForms | Telerik Forums says radGridView1.UseScrollbarsInHierarchy = true; must be included for that logic to work properly and if you remove this statement radGridView1.TableElement.VScrollBar.Value = scrollBarValue; An error occurs if the scrollValue is larger than MaxValue.

I don't want to use that radGridView1.UseScrollbarsInHierarchy = true in my project.

Is there any other way than this? Up to Child is required, and I only want to prevent scroll movement during scroll Endupdate.

thank you!

+ The project you shared also uses .UseScrollbarsInHierarchy = false; In this case, the scroll position remains the same, but the row position of the GridView changes.

 

0
Park
Top achievements
Rank 1
Iron
answered on 13 Jun 2024, 10:09 AM

The scrolling is changing dynamically.
Obviously the update has been completed
After every operation Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout() is called and
It seems that this phenomenon is occurring because the maximum scroll value is called measure and calculated dynamically.

Add RadVScroll to use all miximum, minimum, and value programmatically
When ValueChanged, when the Value of RadVScroll is connected to GridView.TableElement.VScrollBar.Value
The scroll value is the same, but the GridView displays a blank screen (the scroll value seems to have been calculated internally to be large).

Is it possible to prevent the scrolling of the GridView itself and use another scroller (RadVScroller)?
I want to prevent scrolling in any way (EndUpdate).

Please help me. Thank you.

                
Nadya | Tech Support Engineer
Telerik team
commented on 13 Jun 2024, 01:56 PM

Hello, Park,

When you reload a hierarchical grid, it is not enough to store the vertical scrollbar's value. It is necessary to store which rows are expanded as well. I have noticed that this logic is implemented in the provided sample project.

When you expand all rows, scroll to a certain row and press RadButton1, the expanded rows and the vertical scrollbar value are restored.  Note, scrolling the grid affects the Maximum value of the vertical scroll-bar because the height of the last hierarchy element changes during scrolling. You can handle the TableElement.VScrollBar.PropertyChanged event and check how many times the "Maximum" PropertyName is changed and check the values.

If you just update the grid without scrolling, the Maximum is not adjusted and setting the vertical scrollbar's value will return to the correct position without flickering because the stored value takes the same ration of the whole scroll range. But if you scroll and the Maximum is updated, the stored vertical scroll-bar's Value will have another ratio of the whole scroll-bar's range. We can't prevent adjusting the scroll-bar while scrolling since this is the core implementation of the scrollbars,

I hope that this information provides a more clear explanation of what happens in the grid.  

The project in the reffered forum post demonstrate an approach how to restore a scrollbar position in a hierarchy grid where it is important to preserve the expanded states of the rows. Also, UseScrollbarsInHierarchy = false as you want. However, it is not clear to me what exactly you mean with "In this case, the scroll position remains the same, but the row position of the GridView changes." Can you please elaborate? What do you expect to happen with the row position. Note, that after EndUpdate() is called the grid is completely refreshing itself. It is normal if the current row position is changed. If you want you may preserve it as well and restore it after the update. 

Q: Is it possible to prevent the scrolling of the GridView itself and use another scroller (RadVScroller)?

A: If I understand you correctly, you want to prevent the whole build in scrolling in grid it seems that you need to use an external scrollbar, e.g. RadVScrollbar, which will perform the scrolling behavior in the grid. You can disable the build in scrollbars by setting VerticalScrollState to ScrollState.AlwaysHide. If you need to implement your own scrolling functionality, feel free to use RadVScrollbar and manage its value, minimum, maximum according to your needs. 

Please let me know if I can assist you further.

Tags
GridView ScrollBar
Asked by
Park
Top achievements
Rank 1
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Park
Top achievements
Rank 1
Iron
Share this question
or