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
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
Thanks.
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
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?
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.
Vlad
the Telerik team
I'm not sure I understand the question. Can you clarify?
Greetings,Vlad
the Telerik team
As EnableColumnVirtualization="true" EnableRowVirtualization="true" on gridview will not be supported with this feature?
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
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
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.
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
Best regards,
Manuel FelÃcio.
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
I'm looking forward to see it in action!
can you please provide some example how to use lazy loading with WCF?
Thank you.
In ItemsLoading event you can call your WCF method and load the data when available with Load() method.
Kind regards,Vlad
the Telerik team
Thank you.
Can you please explain me following VirtualQueryableCollectionView properties?
1. LoadSize
2. ItemCount
3. TotalItemCount
4. VirtualItemCount
Thank you.
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
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.
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.
@Kalai The official release is scheduled for the middle of November.
Best wishes,Vlad
the Telerik team
Everytime I change VirtualItemCount before or after VirtualQueryableCollectionView.Load method call, i get IndexOutOfRange exception. I have no idea where is problem.
Thank you.
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
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
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!
You can use Load() method of the collection. The first argument (startIndex) you can get from ItemsLoading event.
Best wishes,Vlad
the Telerik team
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; }
}
}
You need to set VirtualItemCount to your real items count.
Sincerely yours,Vlad
the Telerik team
_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?
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
I guess the work around will be something like unhooking and hooking the list?
You can get both total items count and first items in a single request.
Sincerely yours,Vlad
the Telerik team
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
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?
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
Isn't it more normal to load so you can fill a full page at once?
Or am I'm missing something?
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
That is not possible cause it will do the second call anyway :(
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?
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
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??)
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
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 ?