I am trying to implement custom scroll in RAD Grid.When i am doing that i am facing below issues.
1. My Grid data is not synchronized with scroll position.(I am appending new data to the bottom of the collection.)
2. Mouse wheel is not synchornized with my data.
Please suggest how to proceed about this.
Thanks in advance.
7 Answers, 1 is accepted
We would need more info about your project in order to be able to provide you with some clues. How did you go about implementing your custom scrolling logic? Are you following the steps outlined in this blog?
Best wishes,
Milan
the Telerik team
I am getting data from Webservice instead of Ria service.As user scrolls down in a page i check whether data for that page is already loaded or not.If it is not fetched for that particular page i append data for that page in the existing collection .Now as i have appended data i want to adjust scroll position so that based on scroll value it automatically adjusts data in the datagrid visible area.
Let me know if you want me to provide more details.
Thanks.
Have you tried the approach demonstrated in the blog post?
Greetings,Vlad
the Telerik team
Yes i tried same approach.But in your case i believe you are not appending data at the bottom of collection.I am not able to synchronize mouse wheel with scrollviewer's scroll position.Many times it is not raising mouse wheel event due to that i am not able to synchronize both.Let me know how to proceed to solve this scenario or let me know if you want me to provide more detail..
Thanks,
Harsh Bardhan
It would be great if we can take a look at the application that you are building. This will help us identify the problem more easily.
Kind regards,
Milan
the Telerik team
As i am not able to attach project here so i am pasting code snippet here.If you can provide me some location i can upload code there.But i believe this code will help you to identify my problem.
I am facing below issue.
1. When i am scolling mouse it is not changing the scroll position of scroll viewer control but it is scrolling items inside grid.I want to synchronize both.
void RadGrid_SizeChanged(object sender, SizeChangedEventArgs e)
{
var sw = (from c in this.RadGrid.ChildrenOfType<GridViewScrollViewer>()
select c).FirstOrDefault();
//var sw = ((GridViewDataControl)RadGrid).ChildrenOfType<GridViewScrollViewer>().FirstOrDefault();
if (sw != null)
{
sw.IsCustomScrollingEnabled = true;
// sw.MouseWheel += new MouseWheelEventHandler(sw_MouseWheel);
}
sw.ScrollChanged += new ScrollChangedEventHandler(sw_ScrollChanged);
var vsb = sw.ChildrenOfType<ScrollBar>().Where(s => s.Orientation == Orientation.Vertical).FirstOrDefault();
if (vsb != null)
{
ScrollViewer.SetVerticalScrollBarVisibility(RadGrid, ScrollBarVisibility.Visible);
vsb.ClearValue(ScrollBar.ViewportSizeProperty);
vsb.ClearValue(ScrollBar.ValueProperty);
vsb.ClearValue(ScrollBar.MaximumProperty);
vsb.Minimum = 0;
vsb.SmallChange = 1;
vsb.SetValue(
ScrollBar.MaximumProperty, 3.0);
// vsb.SetBinding(ScrollBar.MaximumProperty, new Binding("DataView.PageCount") { Source = source });
vsb.Scroll -= Scroll;
//vsb.Scroll += Scroll;
}
}
//Handling scroll changed event and fetching data from service if required.
void sw_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (e.VerticalChange > 0 && RadGrid.ItemsSource!=null)
{
var vsb = (sender as GridViewScrollViewer).ChildrenOfType<ScrollBar>().Where(s => s.Orientation == Orientation.Vertical).FirstOrDefault();
var pageIndex = (int)Math.Round(vsb.Value);
ServiceReference1.WebService1SoapClient client = new ServiceReference1.WebService1SoapClient();
var selectedRowIndex = (int)Math.Round(vsb.Value * 30);
if (pageIndex >= selectedPageIndex )
{
RadGrid.IsBusy = true;
client.GetReportsCompleted += new EventHandler<ServiceReference1.GetReportsCompletedEventArgs>(cliecnt_GetReports2Completed);
cliecnt.GetReports2Async();
selectedPageIndex++;
}}
}
//Service call will end here and i am appending item into observable collection here
void client_GetReportsCompleted(object sender, ServiceReference1.GetReports2CompletedEventArgs e)
{
ObservableCollection<Report> report = (RadGrid.ItemsSource as ObservableCollection<Report>);
foreach (Report reportitem in e.Result.ReportCollection)
{report.Add(reportitem);}
RadGrid.IsBusy = false;
}
Let me know if you want aything from my side.
Thanks in advance.
You need to login to your account on our web site (www.telerik.com) and create a new support ticket.
There you can attach a zip file (<20MB) containing a runnable test project.
Thank you
Greetings,
Veselin Vasilev
the Telerik team
