Need to know the Scroll Direction

4 posts, 0 answers
  1. Nachiket
    Nachiket avatar
    15 posts
    Member since:
    Jul 2012

    Posted 23 Jan 2013 Link to this post

    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
  2. Nachiket
    Nachiket avatar
    15 posts
    Member since:
    Jul 2012

    Posted 23 Jan 2013 Link to this post

    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
  3. DevCraft banner
  4. Nachiket
    Nachiket avatar
    15 posts
    Member since:
    Jul 2012

    Posted 21 Feb 2013 Link to this post

    Hi,
    Could anybody please reply ?

    -Nachiket 
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 22 Feb 2013 Link to this post

    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.

Back to Top