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

unexpected ItemsLoading calls

5 Answers 65 Views
This is a migrated thread and some comments may be shown as answers.
Eric Lincoln
Top achievements
Rank 1
Eric Lincoln asked on 16 Dec 2010, 11:39 PM
Hi Telerik Team,

I'm using your new VirtualQueryableCollectionView (Q3 SP1 beta) with RadGridView for SL.
I notice that when the scrollbar's thumb is dragged the ItemsLoading callback is called twice.
When the PageDown key is hit or the scrollbar is clicked or the mouse wheel is actuated the ItemsLoading callback is called once as expected.
I set the grid's IsBusy=true at the beginning of the ItemsLoading callback and IsBusy=false just before it returns.
So when the thumb is dragged the grid is busy, then not busy and then busy again until the data appears.
Also the thumb action isn't smooth.

Thanks,
Eric


5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 20 Dec 2010, 08:35 AM
Hi,

Generally  ItemsLoading will be raised multiple times if more than LoadSize data are needed. For example if you bind to a ListBox with 25 visible items on the screen and LoadSize is set to 10 you will get three calls for ItemsLoading.

Greetings,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Eric Lincoln
Top achievements
Rank 1
answered on 20 Dec 2010, 06:30 PM
Hi Vlad,

Vlad you're right if the load size is less than the number of items normally displayed in a view then the LoadingItems callback is called twice -even if one uses the keyboard or mouse to page down. However, in my case the load size was set to 5X times the number items required to populate the current view. Also I did an experiment where I set the load size to exactly the number of rows displayed in the grid and did a page down using either the keyboard or the mouse and the ItemsLoading callback was called only once. However, using the same load size, if I drag the scrollbar thumb the callback is called three times.
Other considerations:
1. The speed of the cursor doesn't have any affect on this behavior.
2. The grid's DataLoadMode is the default.
 
I mentioned the behavior of the IsBusy indicator in my first post but more importantly this incorrect response to the drag op impacts performance. 

Thanks,
Eric
0
SPE
Top achievements
Rank 1
answered on 01 Jun 2011, 01:01 AM
setting the RadGridView's ScrollMode to 'Deferred' will prevent the ItemsLoading event being called twice.
however, it will still be called twice for the topmost items when the RadGridView is initially loaded. but for the rest of the items it will not be called twice. hope this helps.
0
Tim
Top achievements
Rank 1
answered on 03 Jul 2015, 06:18 AM

For the benefit of anyone who come across this thread.  I have been running into the issue of the ItemsLoading Event being called twice for the topmost items.  Originally my code would call to the server twice via a web service to get the items requested.  The SQL that I was running on the server was placing a high load on it and making two requests at the same time doubled the run time of the SQL (e.g. 12 seconds instead of 6 seconds).

To fix this the ItemsLoading Event is received twice.  One call is made to the server and when complete, VirtualDataSource.Load is called twice.  If VirtualDataSource.Load is not called twice sometimes the scroll bar would not represent the true size of the available items.

The detection of the double load is done by one list tracking what is being loaded.  When the ItemsLoading Event fires the second time, A check is done to see if the request is on the first tracking list‚Äč.  If it is on that list, the request is added to another tracking list indicating that it is a double load and the server is not called.  In the call back from the server, VirtualDataSource.Load is called once and t request removed from the first tracking list.  Then a check is done to see if the request is on the second tracking list indicating a double load.  If present there VirtualDataSource.Load is called again.

Tim


0
Dimitrina
Telerik team
answered on 06 Jul 2015, 12:24 PM
Hi Tim,

Thank you for sharing your valuable input to the community.

Regards,
Dimitrina
Telerik
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 Feedback Portal and vote to affect the priority of the items
Asked by
Eric Lincoln
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Eric Lincoln
Top achievements
Rank 1
SPE
Top achievements
Rank 1
Tim
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or