VirtualQueryableCollectionView.ItemsLoading never called when used with RadGridView and RadDataPager

8 posts, 0 answers
  1. Dalibor
    Dalibor avatar
    4 posts
    Member since:
    Jan 2011

    Posted 20 Apr 2011 Link to this post

    Hi all,

    I use VirtualQueryableCollectionView.ItemsLoading together with asynchronous service. I use RadGridView and RadDataPager.
    Everything looks fine until user click pager faster than my service response. If service is slow then VirtualQueryableCollectionView.Load is called later than user clicks on pager again.
    When my service call finishes (for old page 1 -> Load is made for items on page 1) no ItemsLoading is fired for page 2. Even user see already page 2 on the screen no one asked for page 2.
    I tried to use Q1 2011 SP1, but does not work as well.
    Bellow is a source which simulates slow service by right click. Run the code (RadGridView and RadDataPager are bind to Groups). If you right click (simulation of service response) before changing the page then OK. But if you first change the page and just then right click (service response for old page) then no one asks for just shown page.
    What is a right usage in this case?
    Best regards,
    Dalibor

    Code looks like this:

    namespace VirtualPage
    {
       public partial class MainPage : UserControl, INotifyPropertyChanged
       {
          private VirtualQueryableCollectionView groups;
          public VirtualQueryableCollectionView Groups
          {
             get
             {
                if (groups == null)
                {
                   groups = new VirtualQueryableCollectionView();
                   groups.ItemsLoading += HandleItemsLoading;
                   groups.LoadSize = 20;
     
                   // by assigning a value to VirtualItemCount property, we can force the ItemsLoading
                   // event to fire
                   groups.VirtualItemCount = 10000;
                }
     
                return groups;
             }
             private set
             {
                if (groups != value)
                {
                   groups.ItemsLoading -= HandleItemsLoading;
                   groups = value;
     
                   if( PropertyChanged != null)
                   {
                      PropertyChanged(this, new PropertyChangedEventArgs("Groups"));
                   }                                         
                }
             }
          }
           
          public MainPage()
          {
             InitializeComponent();
     
          }
     
          private int startIndex;
          private string[] ar;
     
          // simulation of slow service by right click
          protected override void OnMouseRightButtonDown(System.Windows.Input.MouseButtonEventArgs e)
          {
             base.OnMouseRightButtonDown(e);
     
             // simulation of delayed service callback
             Debug.WriteLine(string.Format("---- Writting {0} count {1}", startIndex, ar.Length));
             groups.Load(startIndex, ar);        
     
             /*
             if((startIndex / groups.PageSize) != groups.PageIndex)
             {
                groups.NeedsRefresh = true;
             }
             */
          }
     
          private void HandleItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
          {
             Debug.WriteLine(string.Format("Asking from {0} count {1}", e.StartIndex, e.ItemCount));
     
             // groups.Load(e.StartIndex, ar);
             // do not load it now, load it later after async call (right click in this demo).
     
             ar = new string[e.ItemCount];
             for (int i = 0; i < e.ItemCount; i++)
             {
                ar[i] = "s" + i;
             }
             startIndex = e.StartIndex;
          }
     
          public event PropertyChangedEventHandler PropertyChanged;
       }
    }

     

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 26 Apr 2011 Link to this post

    Hello Dalibor,

     I've just tried this however everything worked as expected on my end. You can check the attached example application for reference. 

    Best wishes,
    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
  3. DevCraft banner
  4. Dalibor
    Dalibor avatar
    4 posts
    Member since:
    Jan 2011

    Posted 26 Apr 2011 Link to this post

    Hi Vlad,

    Thank you for your reply.

    Your example does not work as well. It looks at the first sight working, but try e.g. this:
    - run application
    - go to 3rd page (because PageSize=10 and LoadSize=20 we need to show page 1, 3 and 5 to initiate requests)
    - right click (everything is fine at this step, Asking from 20 count 20 is initiated)
    - go to 5th page
    - right click
    And you will see that there is no request for 5th page from VirtualQueryableCollectionView even page 5 is on GUI. Page 5 is displayed but data is not requested.

    I am looking forward to hearing from you,
    Dalibor

    Output from the steps above:
    Asking from 0 count 20
    'iexplore.exe' (Silverlight): Loaded 'c:\Program Files (x86)\Microsoft Silverlight\4.0.60310.0\en-US\System.Windows.debug.resources.dll'
    ---- Writting 0 count 20
    Asking from 20 count 20
    ---- Writting 20 count 20
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 26 Apr 2011 Link to this post

    Hello,

     I've attached another version of the same project now with some data. 

    Kind regards,
    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
  6. Dalibor
    Dalibor avatar
    4 posts
    Member since:
    Jan 2011

    Posted 26 Apr 2011 Link to this post

    Hello Vlad,

    when we load data fast enough or even immediately (synchronously) like your second sample then everything works. No doubt.

    But if our service is asynchronous and slower than user clicks to pager then this incorrect behavior can be observed.

    Could you please step back to your first sample and try these steps, please?
    A. run application
    B. go to 3rd page by clicking pager
    C. right click (this is a simulation of slow service response for page 1)
    D. go to 5th page by clicking pager
    E. right click (this is a simulation of slow service response for page 3)

    Now there shall be a request for page 5 (because page 5 is visible now), but no request is coming from VirtualQueryableCollectionView.

    Best regards,
    Dalibor
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 26 Apr 2011 Link to this post

    Hi Dalibor,

     I've attached again new version of the same demo with more info how to load data from a BackgroundWorker after 3000 milliseconds.

    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
  8. Dalibor
    Dalibor avatar
    4 posts
    Member since:
    Jan 2011

    Posted 26 Apr 2011 Link to this post

    Hi Vlad,

    thank you for uploading this solution. It is reproducible in this last solution as well.

    Follow these steps:
    - open application
    - wait for data
    - click 4 times to page next within less than 3 seconds (your refresh is 3 second). Result shall be page 5.
    - wait more than 3 seconds, e.g. 10 seconds
    - page 5 is displayed with no data -> this is wrong

    Attached result of above steps.
    Could you reproduce the bug now?

    Best regards,
    Dalibor
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 29 Apr 2011 Link to this post

    Hi Dalibor,

     You are right - unfortunately we are still not sure what is causing this. The only option I can offer you at the moment is to disable the pager during loading and re-enable it once the data are loaded. 

    Please check the attached application for more info. 

    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
Back to Top
DevCraft banner