Hi
We have a requirement to load thousand of records in grid control and tried to implament load on demand using VirtualQueryableCollectionView.
But if i load 5 lak records in my test page and tested with normal loading techniquies as well as VirtualQueryableCollectionView.
both are getting same time to load (4-5 seconds).
Normal way
public UCTSGridTest()
{
InitializeComponent();
CollList = Club.GetClubs();
clubsGrid.ItemsSource = CollList;
}
Using VirtualQueryableCollectionView
public UCTSGridTest()
{
InitializeComponent();
CollList = Club.GetClubs();
view = new VirtualQueryableCollectionView() { LoadSize = 10, VirtualItemCount = 500000 };
DataContext = view;
view.ItemsLoading += new EventHandler<VirtualQueryableCollectionViewItemsLoadingEventArgs> (view_ItemsLoading);
}
void view_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
{
view.Load(e.StartIndex, CollList.Skip(e.StartIndex).Take(e.ItemCount));
}
Did i miss anything
10 Answers, 1 is accepted
Yes. You are getting all records in both cases on initial load:
InitializeComponent();
CollList = Club.GetClubs();
....
Regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
VirtualQueryableCollectionView is used to load the intial set of records (example 10) on initial page load and loads set of records throuch scroll bar selection.
In this case, it should not load all records into grid.
can you clarify
You may need to load your records from a database server or service instead in-memory to know what's the difference.
Greetings,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Thanks for your clarifications. I wil do that and update you
Thanks
Balsuyambu
I got the 5 Lak records from web service and bind to the grid in normal loading techniquies as well as VirtualQueryableCollectionView and find below the code.
BOTH way are getting same time.
Normal way
void objPlayer_getPlayersCompleted(object sender, wsPlayers.getPlayersCompletedEventArgs e)
{
clubsGrid.ItemsSource = e.Result;
}
Using VirtualQueryableCollectionView
ObservableCollection<ToucScreenAppln.wsPlayers.Player> lplayer;
void objPlayer_getPlayersCompleted(object sender, wsPlayers.getPlayersCompletedEventArgs e)
{
lplayer = e.Result;
view = new VirtualQueryableCollectionView() { LoadSize = 10, VirtualItemCount = e.Result.Count };
DataContext = view;
view.ItemsLoading += new EventHandler<VirtualQueryableCollectionViewItemsLoadingEventArgs>(view_ItemsLoading);
}
void view_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
{
view.Load(e.StartIndex, lplayer.Skip(e.StartIndex).Take(e.ItemCount));
}
Please let me know the implementation of VirtualQueryableCollectionView approach is correct ?
Are you loading your data on portions using ItemsLoading event? I don't see any call to your service from ItemsLoading.
Greetings,Vlad
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
I got the object from webservice in objPlayer_getPlayersCompleted method and convert this object into ObservableCollection object and bind ObservableCollection object into item loading event
Please find below the highlighted lines
ObservableCollection<ToucScreenAppln.wsPlayers.Player> lplayer;
void objPlayer_getPlayersCompleted(object sender, wsPlayers.getPlayersCompletedEventArgs e)
{
lplayer = e.Result;
view = new VirtualQueryableCollectionView() { LoadSize = 10, VirtualItemCount = e.Result.Count };
DataContext = view;
view.ItemsLoading += new EventHandler<VirtualQueryableCollectionViewItemsLoadingEventArgs>(view_ItemsLoading);
}
void view_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
{
view.Load(e.StartIndex, lplayer.Skip(e.StartIndex).Take(e.ItemCount));
}
is this correct approach?
The idea is to call your service with two parameters in ItemsLoading - e.StartIndex and e.ItemCount. In this case you will load only portion of the data not all of it.
All the best,Vlad
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
Do you mean to say if i want to load 10 rows then service should get the 10 rows of data from item loading event based on start index and item count.
We can call web service through Async mode then how to call service through item loading event.
if you have any sample project, please attache.
thanks
Balsuyambu s.
Yes. You should call the service with the parameters returned from ItemsLoading. Later you can call Load() method of the virtual collection to load your data into the collection. I suggest you to check both our demos an documentation for more info. You can check also my blog posts:
http://blogs.telerik.com/vladimirenchev/posts/11-04-18/telerik-data-virtualization-wcf-ria-services-and-visual-studio-async-ctp.aspx
http://blogs.telerik.com/vladimirenchev/posts/10-12-09/server-sorting-and-filtering-with-wcf-ria-services-and-telerik-data-virtualization-for-silverlight.aspx
http://blogs.telerik.com/vladimirenchev/posts/10-10-20/data-virtualization-for-your-silverlight-and-wpf-applications.aspx
Vlad
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.