Data Virtualization

2 posts, 0 answers
  1. islam
    islam avatar
    4 posts
    Member since:
    Nov 2010

    Posted 20 Oct 2011 Link to this post

    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

     

     

     

     

     

     

     

     

  2. islam
    islam avatar
    4 posts
    Member since:
    Nov 2010

    Posted 22 Oct 2011 Link to this post

    ......
Back to Top