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

VirtualQueryableCollectionView.ItemsLoading never called when used with RadGridView and RadDataPager

7 Answers 382 Views
Data Virtualization
This is a migrated thread and some comments may be shown as answers.
Dalibor
Top achievements
Rank 1
Dalibor asked on 20 Apr 2011, 05:13 PM

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;
   }
}

 

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 26 Apr 2011, 09:32 AM
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
0
Dalibor
Top achievements
Rank 1
answered on 26 Apr 2011, 10:49 AM
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
0
Vlad
Telerik team
answered on 26 Apr 2011, 02:03 PM
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
0
Dalibor
Top achievements
Rank 1
answered on 26 Apr 2011, 02:28 PM
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
0
Vlad
Telerik team
answered on 26 Apr 2011, 02:37 PM
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
0
Dalibor
Top achievements
Rank 1
answered on 26 Apr 2011, 04:57 PM
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
0
Vlad
Telerik team
answered on 29 Apr 2011, 01:46 PM
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
Tags
Data Virtualization
Asked by
Dalibor
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Dalibor
Top achievements
Rank 1
Share this question
or