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

LazyLoading Grid, ScrollBarValueChanged?

50 Answers 393 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 24 Sep 2010, 06:24 PM
Hello,

we want to implement LazyLoading to RadGrid. The SQL view returns now rowNumbers.
I have looked at a few approaches in google and this forum but they look like work arounds.

Do you have a mentioned way to implement this functionality with (enabled sorting)?


Thank you.

50 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 27 Sep 2010, 06:53 AM
Hi Simon,

After two/three weeks we will publish our Q3 2010 Beta and you will able to find our new VirtualQueryableCollectionView. This class is extended version of our QueryableCollectionView and will query items only if needed. Here is small video from our Q3 Beta QSF. 

All the best,
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
Simon
Top achievements
Rank 1
answered on 29 Sep 2010, 09:45 AM
Thank you for your information, its good to hear. Hopefully you publish some examples which use WCF Service in a well performing way.


Thanks.
0
Vlad
Telerik team
answered on 29 Sep 2010, 10:13 AM
Hi,

 Indeed the demo in our examples is using service to populate the data on the fly. You can use actually any kind of service to do that - plain WCF service, Web service, WCF Data Service, WCF RIA Service, OData, etc. since that collection will raise an event (ItemsLoading) where you can call your service with provided data.  

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
Simon
Top achievements
Rank 1
answered on 29 Sep 2010, 10:23 AM
Great! I really look forward to the release of the Q3!
0
ss
Top achievements
Rank 1
answered on 12 Oct 2010, 01:59 PM

For example I have 10 000 000 articles. Is it possible to keep in memory only for example 1000 articles? Thank you.

When Q3 Beta will be released?

0
Vlad
Telerik team
answered on 13 Oct 2010, 09:23 AM
Hello,

The collection will be populated with empty items (null in most cases) to total items count and will load real items only when requested from IList indexer. Unfortunately UI controls with virtualization (ListBox, RadGidView, etc.) will unable to work with collection where Count is not equal to real items count.  

The beta will be released this week. 

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
Niclas Pehrsson
Top achievements
Rank 1
answered on 13 Oct 2010, 12:36 PM
When can we expect that UI virtualization is supported for this feature? I can't really see the big problem why it shouldn't.
0
Vlad
Telerik team
answered on 13 Oct 2010, 12:38 PM
Hello ,

 I'm not sure I understand the question. Can you clarify?

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
Niclas Pehrsson
Top achievements
Rank 1
answered on 13 Oct 2010, 12:40 PM
I took this meaning ". Unfortunately UI controls with virtualization (ListBox, RadGidView, etc.) will unable to work with collection where Count is not equal to real items count.  "

As EnableColumnVirtualization="true" EnableRowVirtualization="true" on gridview will not be supported with this feature?
0
Vlad
Telerik team
answered on 13 Oct 2010, 12:57 PM
Hello Niclas,

 I've tried to explain that UI virtual controls cannot support a collection where count for example will return 100 however you will have only 10 items. Our collection (VirtualQueryableCollectionView) will create 100 nulls in this case and will replace these nulls with real items when requested. 

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
Niclas Pehrsson
Top achievements
Rank 1
answered on 14 Oct 2010, 08:25 AM
Are there any possibilities to get the beta assemblies right now? We would really need this feature.
0
Vlad
Telerik team
answered on 14 Oct 2010, 09:33 AM
Hi,

 We will do our best to upload the beta before the end of this week. In the meantime I'm attaching small example application with simple ListBox bound to WCF RIA service on demand. You can get also the grid related binaries from the project. 

Sincerely yours,
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
Niclas Pehrsson
Top achievements
Rank 1
answered on 14 Oct 2010, 12:02 PM
Great thanks
0
Kalai
Top achievements
Rank 1
answered on 15 Oct 2010, 01:13 PM
Hi,

       We would like to implement lazy loading in WPF. When I tried to use VirtualQueryableCollectionView class, it expects System.Windows assembly which contradicts with PresentationFramework assembly.

       It would be really great if you can help me on this.

Thanks,
Kalai.
0
Vlad
Telerik team
answered on 15 Oct 2010, 01:43 PM
Hello,

 The attached binaries in the previous project are for Silverlight. I'm attaching WPF application to illustrate you how to use VirtualQueryableCollectionView with IQueryable.

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
Manuel Felício
Top achievements
Rank 1
answered on 15 Oct 2010, 03:32 PM
Hi, I have my own implementation of ICollectionView, which either does in-memory queries using LINQ or does server-side queries using wcf ria services. Will I be able to use this functionallity with my own ICollectionView implementation? I'd really like to be able to do paging through the scrollbar.

Best regards,
Manuel Felício.
0
Vlad
Telerik team
answered on 15 Oct 2010, 03:37 PM
Hi Manuel,

 You can use the ItemsLoading even to call your collection methods and Load() method to load data once you have it. 

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
Manuel Felício
Top achievements
Rank 1
answered on 16 Oct 2010, 10:42 AM
That sounds promising :)

I'm looking forward to see it in action!
0
ss
Top achievements
Rank 1
answered on 20 Oct 2010, 02:30 PM

can you please provide some example how to use  lazy loading with WCF? 


Thank you.

0
Vlad
Telerik team
answered on 20 Oct 2010, 02:39 PM
Hello ss,

 In ItemsLoading event you can call your WCF method and load the data when available with Load() method.

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
ss
Top achievements
Rank 1
answered on 20 Oct 2010, 02:59 PM

Thank you.

Can you please explain me following VirtualQueryableCollectionView properties?

1. LoadSize

2. ItemCount 

3. TotalItemCount 

4. VirtualItemCount

Thank you.

0
Vlad
Telerik team
answered on 20 Oct 2010, 03:02 PM
Hi,

 ItemCount and TotalItemCount are inherited from QueryableCollectionView. You can use LoadSize to define maximum number of items requested at once and you should set VirtualItemCount to the total number of items available on the server-side for example.

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
ss
Top achievements
Rank 1
answered on 21 Oct 2010, 09:59 AM

Thank you very much,

 

Everythings works fine but I have some different problem. How can I change VirtualItemCount after/before load data? Is it possible or no? I need to change VirtualItemCount because number of loded items is not constant. For example user can delete articles or add new articles to database.

Next question: 

I would like to set VirtualItemCount = 500 000, For example one item size = 500KB. Do you keep in memory all loaded items or do you kepp in memory only specific number of items? 

Thank you.

0
Kalai
Top achievements
Rank 1
answered on 21 Oct 2010, 10:14 AM
Hi Vlad,

           Thank you so much for your promising answers. We are early waiting for Q3 release for implementing this feature. Could you please let us know when we will get Q3 RAD Controls Suite?

Thanks,
Kalai.
0
Vlad
Telerik team
answered on 21 Oct 2010, 01:06 PM
@ss If you set VirtualItemCount runtime the collection will refresh itself. When you have 500 000 the collection will create 500 000 nulls and will replace them when the real item is loaded. Once the item is loaded (not null) -  this item will be cached. 

 @Kalai The official release is scheduled for the middle of November. 

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
ss
Top achievements
Rank 1
answered on 21 Oct 2010, 04:17 PM

Everytime I change VirtualItemCount before or after VirtualQueryableCollectionView.Load method call, i get IndexOutOfRange exception. I have no idea where is problem.

Thank you.

0
Vlad
Telerik team
answered on 21 Oct 2010, 04:31 PM
Hi ss,

 I've just tried this however didn't get any exception. Please check the attached application for reference - you can comment also ItemsLoading event handler. 

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
ss
Top achievements
Rank 1
answered on 22 Oct 2010, 07:41 AM
Thank you. Your example helped me to find my problem. DataLoadMode cannot be se to Asynchronous. Now, everythings works fine.
0
Vlad
Telerik team
answered on 22 Oct 2010, 08:56 AM
Hi ss,

 Thank you for reporting this! We've fixed this immediately and I've added 1000 Telerik points to your account. 

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
Simon
Top achievements
Rank 1
answered on 28 Oct 2010, 06:32 PM
Hello,

i tried ur sample and addopt it to work with a custom class list from a wcf service. but i didnt get it to work! its probably my fault but your documentation and samples are not very detailed too... i get a IList<myClass> back from the wcf service, can u show me how i can load the right data and how to load it to the VirtualQueryableCollectionView?

Thank u very much!
0
Vlad
Telerik team
answered on 29 Oct 2010, 07:03 AM
Hello Simon,

 You can use Load() method of the collection. The first argument (startIndex) you can get from ItemsLoading event. 

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
Simon
Top achievements
Rank 1
answered on 29 Oct 2010, 09:06 AM
Hello,

thank u for your response. I tried it but it just loads 100 items in the grid, how it is given in the

VirtualItemCount. When the end is reached the itemsloading event is not fired again.
Can u tell me what im doing wrong?

Thank you.

namespace

 

 

GridTelerikQ32010Test

 

{

 

 

public partial class MainPage : UserControl

 

{

 

 

VirtualQueryableCollectionView view;

 

 

 

public MainPage()

 

{

InitializeComponent();

view =

 

new VirtualQueryableCollectionView() { LoadSize = 10, VirtualItemCount = 100 };

 

view.ItemsLoading +=

 

new EventHandler<VirtualQueryableCollectionViewItemsLoadingEventArgs>(view_ItemsLoading);

 

 

DataContext = view;

}

 

 

void view_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)

 

{

 

 

view.Load(e.StartIndex, GenerateData().Skip(e.StartIndex).Take(e.ItemCount));

 

 

}

 

 

public List<Bestellpositionen> GenerateData()

 

{

 

 

var list = new List<Bestellpositionen>();

 

 

 

for(int i=0; i < 500; i++)

 

{

list.Add(

 

new Bestellpositionen() {ID= i, Name = "element"+i.ToString()});

 

}

 

 

return list;

 

}

}

 

 

 

public class Bestellpositionen

 

{

 

 

public int ID { get; set; }

 

 

 

public string Name { get; set; }

 

}

}

0
Vlad
Telerik team
answered on 29 Oct 2010, 09:38 AM
Hello Simon,

 You need to set VirtualItemCount to your real items count. 

Sincerely yours,
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
Simon
Top achievements
Rank 1
answered on 29 Oct 2010, 11:15 AM
Thank you, it works for me now.
0
Niclas Pehrsson
Top achievements
Rank 1
answered on 03 Nov 2010, 11:30 AM
     Private Sub OnArticlesLoaded(ByVal startIndex As Integer, ByVal result As ListLoadResult(Of Article))
            _articles.VirtualItemCount = result.TotalRows
            _articles.Load(startIndex, result.Items)
        End Sub

When changing the VirtualItemCount the lists automatically fires the ItemsLoading event again. Even if I'm already has loaded the first ones.
Can I somehow turn of the list to not fire the event when changing VirtualItemCount?
0
Vlad
Telerik team
answered on 03 Nov 2010, 12:26 PM
Hi Niclas,

 When you change VirtualItemCount the entire collection will be regenerated from scratch and ItemsLoading will be raised for the first items. 

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
Niclas Pehrsson
Top achievements
Rank 1
answered on 03 Nov 2010, 12:42 PM
Well it means that for every search or filtering, and first time I load the collection I need two wcf calls, when I could do it with just one.

I guess the work around will be something like unhooking and hooking the list?
0
Vlad
Telerik team
answered on 03 Nov 2010, 12:45 PM
Hello Niclas,

 You can get both total items count and first items in a single request. 

Sincerely yours,
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
Niclas Pehrsson
Top achievements
Rank 1
answered on 03 Nov 2010, 12:46 PM
Yes, but when the VirtualItemCount changes it will make another request?
0
Vlad
Telerik team
answered on 03 Nov 2010, 01:02 PM
Hello Niclas,

 The idea is that when you filter you will get already filtered "first page" from the server + total items count and the next request(s) will be because of more data needed.

All the best,
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
Niclas Pehrsson
Top achievements
Rank 1
answered on 03 Nov 2010, 02:14 PM
Okeay, our approach were to load the first 50 at the same time we got the count and then fill it, to avoid unnecessary calls.
But right after the first call that should be enough the list queries for the same (startindex = 0, itemcount = 50) again.
Are you with me what I'm looking for?

So yours idea is to not load the whole first page, I will need to have 2 calls either way?
0
Vlad
Telerik team
answered on 03 Nov 2010, 02:20 PM
Hi Niclas,

 Generally the collection will load more items if something is trying to access the IList indexer. For example if you have 10 for LoadSize however you see 15 items in a ListBox you will get 20 items loaded - two calls. 

Sincerely yours,
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
Niclas Pehrsson
Top achievements
Rank 1
answered on 03 Nov 2010, 02:57 PM
Isn't that a bad approach, it will make the application to make more calls?
Isn't it more normal to load so you can fill a full page at once?
Or am I'm missing something?
0
Vlad
Telerik team
answered on 03 Nov 2010, 03:08 PM
Hi Niclas,

 If you don't get the second call in my example you will get ListBox filled only with 10 items however you will see 15 UI items. Five items will empty on screen.

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
Niclas Pehrsson
Top achievements
Rank 1
answered on 03 Nov 2010, 04:14 PM
Well but if you would have loaded it with 15 directly to avoid the second call?
That is not possible cause it will do the second call anyway :(
0
Alex
Top achievements
Rank 1
answered on 24 Nov 2010, 05:38 AM
Hi everyone,

I tried the sample above (silverlightapplication1.zip) but if I load the contents in to a normal SDK datagrid, it will crash Silverlight when the datagrid scrolls to null items (if it doesn't scroll to null items, it works fine thou)

Is this resolved in later versions?
0
Vlad
Telerik team
answered on 24 Nov 2010, 07:52 AM
Hello,

 Unfortunately I'm unable to open the link to the project - can you post more info? Why you want to use standard DataGrid instead RadGridView in this case?

Regards,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Alex
Top achievements
Rank 1
answered on 24 Nov 2010, 08:20 AM
Right now I'm evaluating collections/data loading mechanisms (and creating my own) and so I'm always testing them with a wide variety of controls.

I had noticed the gridview and datagrid's inability to take null's before, but the telerik gridview is somehow able to take nulls (but only from a virtual queryable collection??)
0
Vlad
Telerik team
answered on 24 Nov 2010, 08:33 AM
Hi,

 Yes we have special technique to avoid such problems - I'm afraid that most of standard Silverlight controls cannot work in such scenarios. 

Best wishes,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Felix De Lille
Top achievements
Rank 1
answered on 04 Mar 2011, 02:07 AM
Hello,

So if the user sorts and/or filters with lazyloading:
- we have to implement itemloading event
- see if user wants to sort and/or filter
- implement the right WCF methods and pass the filter/sorting params
- get the totalItemCount of 1 wcf method first => put it in VirtualList.ItemCount => fires again itemloading event
- get the right filtered list of items via another wcf method

Is this the correct workflow ?
Tags
General Discussions
Asked by
Simon
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Simon
Top achievements
Rank 1
ss
Top achievements
Rank 1
Niclas Pehrsson
Top achievements
Rank 1
Kalai
Top achievements
Rank 1
Manuel Felício
Top achievements
Rank 1
Alex
Top achievements
Rank 1
Felix De Lille
Top achievements
Rank 1
Share this question
or