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

[Solved] Data Virtualization

1 Answer 85 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
islam
Top achievements
Rank 1
islam asked on 20 Oct 2011, 10:58 AM

hello,

am using "VirtualQueryableCollectionView " for data virtualizing in a grid view, in the follwoing code.

 

Dictionary<int, int> LoadingArray = new Dictionary<int, int>();
 
       VirtualQueryableCollectionView _DataList;
       public VirtualQueryableCollectionView DataList
       {
           get
           {
               if (_DataList == null)
               {
                   LoadingArray = new Dictionary<int, int>();
 
                   _DataList = new VirtualQueryableCollectionView();
                   _DataList.VirtualItemCount = 30; // Force ItemsLoading to get the real total item count and data in a single request
                   _DataList.LoadSize = 10;
                   //    _DataList.TotalItemCount
 
                   _DataList.FilterDescriptors.CollectionChanged += FilterDescriptorsChanged;
 
                   _DataList.ItemsLoading += Customers_ItemsLoading;
                    
 
               }
 
               return _DataList;
           }
           private set
           {
               if (this._DataList != value)
               {
                   _DataList.ItemsLoading -= Customers_ItemsLoading;
 
                   this._DataList = value;
                   this.FirePropertyChanged("DataList");
               }
           }
       }
 
 
       void Customers_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
       {
           //if (DataCount == 0)
           //{
           //    DataList.Load(0,new List<object>());
           //    return;
           //}
           //if (!shouldLoad)
           //{
           //    shouldLoad = true;
           //    return;
           //}
           //to prevent from refreshing the first pages whent change the count just make an array of int that holds the start indexes and check on loading if the index exists in the array don't load.
           if (this.filterChangedArgs != null)
           {
               if (!LoadingArray.Keys.Contains(e.StartIndex))
               {
 
 
                   LoadingArray.Add(e.StartIndex, e.StartIndex);
                  
                   //FilterSerializer serializer = new FilterSerializer();
Context.Load(Context.GetDataQuery(datainfo), LoadBehavior.RefreshCurrent, CustomersLoaded, e.StartIndex);
               }
           }
             }

 now at first i set the property VirtualItemCount to 30 because i dont have the real count of my data,and in each call i store the call startIndex in the LoadingArray , at the same time i call a query to get the data count,while the datalist is loading data the count returns

i use it to set VirtualItemCount,now the list will call the dataload again so i check if it called before and if yes i ignore it, the problem is after i set VirtualItemCount property the loaded data is lost why do this happen?

DataList.VirtualItemCount =DataCount;

thanks in advance

 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
islam
Top achievements
Rank 1
answered on 22 Oct 2011, 09:50 AM
......
Tags
GridView
Asked by
islam
Top achievements
Rank 1
Answers by
islam
Top achievements
Rank 1
Share this question
or