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

VirtualQueryableCollectionView

5 Answers 218 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sriram
Top achievements
Rank 2
Sriram asked on 20 Oct 2010, 08:46 AM
Dear Telerik Team,

How to use VirtualQueryableCollectionView with paging.. for large amount of data we r using domaindatasource. can i use VirtualQueryableCollectionView for the the alternate for DomainDataSource. please post example code

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 20 Oct 2010, 09:00 AM
Hello,

 Have you checked our demo? The grid is bound to VirtualQueryableCollectionView and data are loaded on demand from WCF RIA Service. You can download our QSF and check ExamplesDataContext in DataVirtualization project. I'm post the code here as well:

public class ExamplesDataContext : ViewModelBase
    {
        NorthwindDomainContext _Context;
        public NorthwindDomainContext Context
        {
            get
            {
                if (_Context == null)
                {
                    _Context = new NorthwindDomainContext();
 
                }
 
                return _Context;
            }
        }
 
        VirtualQueryableCollectionView _Customers;
        public VirtualQueryableCollectionView Customers
        {
            get
            {
                if (_Customers == null)
                {
                    _Customers = new VirtualQueryableCollectionView();
                    _Customers.VirtualItemCount = 100; // Force ItemsLoading to get the real total item count and data in a single request
                    _Customers.LoadSize = 10;
 
                    _Customers.ItemsLoading += Customers_ItemsLoading;
                }
 
                return _Customers;
            }
            private set
            {
                if (this._Customers != value)
                {
                    _Customers.ItemsLoading -= Customers_ItemsLoading;
 
                    this._Customers = value;
                    this.OnPropertyChanged("Customers");
                }
            }
        }
 
        void Customers_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
        {
            EntityQuery<Customer> query = Context.GetCustomersQuery();
            query.IncludeTotalCount = true;
            Context.Load<Customer>(EntityQueryExtensions.Sort<Customer>(query, Customers.SortDescriptors).Skip(e.StartIndex).Take(e.ItemCount),
                LoadBehavior.RefreshCurrent, CustomersLoaded, e.StartIndex);
        }
 
        private void CustomersLoaded(LoadOperation lo)
        {
            if (lo.TotalEntityCount != Customers.VirtualItemCount)
            {
                Customers.VirtualItemCount = lo.TotalEntityCount;
            }
 
            Customers.Load((int)lo.UserState, lo.Entities);
        }
 
        public void ClearLoadedCustomers()
        {
            this.Customers = null;
        }
    }


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
Sriram
Top achievements
Rank 2
answered on 20 Oct 2010, 11:48 AM
Dear Telerik Team,

it is working great.
can i use

VirtualQueryableCollectionView as an alternate of domaindatasource??

0
Vlad
Telerik team
answered on 20 Oct 2010, 12:21 PM
Hello,

Indeed you can use the collection to load data on demand similar to DomainDataSource 
and I'm happy to inform you that we will release our own DomainDataSource with the first service pack of our Q3 - most probably early December this year. 

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
Hicham
Top achievements
Rank 1
answered on 20 Oct 2010, 08:34 PM
I have not used your class yet but I would like to understand the logic.
Does it just encapsulate the order().skip().take() logic on the client side or does it offer some caching on the server side?
Thank you.
0
Vlad
Telerik team
answered on 21 Oct 2010, 07:41 AM
Hello,

 VirtualQueryableCollectionView will cache item on the client once the item is loaded. 

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
Tags
General Discussions
Asked by
Sriram
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Sriram
Top achievements
Rank 2
Hicham
Top achievements
Rank 1
Share this question
or