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

[Solved] Custom Scroll in Rad Grid

7 Answers 201 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
HARSH
Top achievements
Rank 1
HARSH asked on 18 Aug 2010, 02:29 PM
Hi,

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

Sort by
0
Milan
Telerik team
answered on 19 Aug 2010, 01:18 PM
Hello HARSH,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
HARSH
Top achievements
Rank 1
answered on 19 Aug 2010, 04:31 PM
Hi,

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.
0
Vlad
Telerik team
answered on 20 Aug 2010, 06:48 AM
Hi,

 Have you tried the approach demonstrated in the blog post?

Greetings,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
HARSH
Top achievements
Rank 1
answered on 25 Aug 2010, 07:42 AM
Hi ,

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
0
Milan
Telerik team
answered on 25 Aug 2010, 07:52 AM
Hi HARSH,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
HARSH
Top achievements
Rank 1
answered on 25 Aug 2010, 10:42 AM
Hi,

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.

0
Veselin Vasilev
Telerik team
answered on 31 Aug 2010, 02:09 PM
Hello HARSH,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
HARSH
Top achievements
Rank 1
Answers by
Milan
Telerik team
HARSH
Top achievements
Rank 1
Vlad
Telerik team
Veselin Vasilev
Telerik team
Share this question
or