This is a migrated thread and some comments may be shown as answers.
Need to know the Scroll Direction
3 Answers 27 Views
This is a migrated thread and some comments may be shown as answers.
Nachiket
Top achievements
Rank 1
Nachiket asked on 23 Jan 2013, 04:31 PM
Hello,
I am using the VirualQueryableCollectionView for displaying about 10K+ records with the LoadSize of 50 records. I have hooked up the "ItemsLoading" event with control and then I selectively Load the Data considering the eventArg.StartIndex and LoadSize. And then the RadGridView displays those loaded records. 

Each time I get the "ItemsLoading" event called, I get the "VirtualQueryableCollectionViewItemsLoadingEventArgs"argument with StartIndex and ItemsCount. So I load the records from database which Correspond to the StartIndex and StartIndex+ItemsCount

So when I begin i recieve event.StartIndex=0 and ItemsCount=50 ==> Load Records from 0 to 0+50
when I scroll down I get event e.StartIndex=50 and ItemsCount=50 ==> Load Records from 50 to 50+50
when I scroll down I get event e.StartIndex=100 and ItemsCount=50 ==> Load Records from 100 to 100+50
... and so on 
this works fine when I am scrolling forward.

Here is my problem.

Now with the ScrollMode=Deffered I directly go to the bottom of the list. 
it loads the records considering the LoadSize of 50. so I get Last record and 50 records prior to that.
when I start scrolling backwards, I see that the Event gets fired very often than when I was scrolling upwards. After I analyzed the EventArgument values It seemed that, "VirtualQueryableCollectionView" thinks that its startIndex is some X Value and then I need to Load that X + the LoadSize, Because I do not know the Scroll Direction I am always loading records in a range from the StartIndex (coming from EventArgument) + LoadSize(50) in my case. 
This results into too many requests while scrolling UP.

Is there a way to find out the scroll direction, so that I cam make better decision about which Items to Load ?
OR is there any other means to resolve this issue ?

Cheers,
Nachiket

3 Answers, 1 is accepted

Sort by
0
Nachiket
Top achievements
Rank 1
answered on 23 Jan 2013, 04:42 PM
I looked at the Demo of DataVirtualization
http://demos.telerik.com/silverlight/#DataVirtualization/FirstLook
This also suffers from the same problem while scrolling UP. It frequently makes requests to load more data and unfortunately the StartIndex Often starts with the TOP record on the screen and then It loads that Top Record Number + LoadSize in the wrong direction. 
This implementation ends up loading just 1 new record every time you scroll the list in UPward direction

Cheers,
Nachiket
0
Nachiket
Top achievements
Rank 1
answered on 21 Feb 2013, 10:17 PM
Hi,
Could anybody please reply ?

-Nachiket 
0
Vlad
Telerik team
answered on 22 Feb 2013, 06:55 AM
Hi Nachiket,

 Indeed when you scroll up the collection will raise the event with one item since only one item is requested from the items control (in this case RadGridView). If you want you can cache your previously requested index and when the event is raised check if the new index is greater or not from the previous index. 

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Asked by
Nachiket
Top achievements
Rank 1
Answers by
Nachiket
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or