In my application, I fill Rad grid view with near about 1000 records and refill the gird in every 45 seconds. In mid of refresh, If user has scrolled the grid vertically or horizontally then after refresh Horizontal and vertical scrolling bar moves onto to the top and left corner. So I just want to fix them where user left the scrolling bar and for that I need the value of scrolling offset of rad grid view but I am not able to fetch that.
Please help me to get and reset Scrolling Vertical and horizontal offset value from Rad Grid View.
8 Answers, 1 is accepted
You can get the GridView's ScrollViewer like so:
var viewer = this.radGridView1.FindChildByType<GridViewScrollViewer>();Kind regards,
Yavor Georgiev
the Telerik team
I've been trying to accomplish something similar as well... except, I'm trying to refresh the cells of the grid after a cell is edited. Within the cell's CellEditEnded event, I have the following code:
var scrollViewer = this.ChildrenOfType<GridViewScrollViewer>().FirstOrDefault(); var verticalPosition = scrollViewer.VerticalOffset; var horizontalPosition = scrollViewer.HorizontalOffset; Dispatcher.BeginInvoke(() => { Items.Refresh(); scrollViewer.ScrollToHorizontalOffset(horizontalPosition); scrollViewer.ScrollToVerticalOffset(verticalPosition); }); This works fine if I click off in to another cell to trigger the EditEnded event, but if I use the Enter or Tab key, the screen moves around and then doesn't move back to the same position it was in originally. Any ideas of what could cause this or any suggestions for alternative solutions?
Thanks,
-Jarred Froman
Can you post more info about your scenario? Usually if the data object is INotifyPropertyChanged the cell value will be updated automatically - you do not need to scroll or stuff like this.
Regards,Vlad
the Telerik team
Thanks,
-Jarred Froman
If I understand the requirement correctly - you need to conditionally colorize cells, based on their value.
The typical approach here would be.
1. Your business object should implement the INotifyPropertyChanged interface. This way , when the value changes , RadGridView will know to refresh the UI.
2. You may bind the color of the cell to the value, using an IValueConverter. ( something like value to color converter) .
In case this sounds obscure, just let me know and I will provide some additional assistance.
Kind regards,
Pavel Pavlov
the Telerik team
Thanks,
-Jarred Froman
You can check this blog post and this demo for more info about conditional formating of cells.
All the best,Vlad
the Telerik team
