recursive loading data when scrolling (virtualCollection)

2 posts, 0 answers
  1. nidhal ben hamadou
    nidhal ben hamadou avatar
    13 posts
    Member since:
    Oct 2009

    Posted 12 Mar 2015 Link to this post

    Hi,
    I use a VirtualCollection binded to a RadGridView (Version 2015.1.225.45    framework 4.5.1 ) 
    My scenario is : when i click on the button move last  VirtualCollectionPays.MoveCurrentToLast(); the scrollbar of gridview move to last position and when i click on the button move fist  VirtualCollectionPays.MoveCurrentToFirst(); the scrollbar of gridview move to fist position .

    Error :  when i move to the last and come back to first position the loading event in virtual collection make a recursive call and load all Items in the database .
    I use a plain wcf services  not rest nether data services .
    i use an async methode in the loading event .

    //
    public async void LoadData()
           {
               VirtualCollectionPays = new VirtualQueryableCollectionViewExtended<Pay>() { LoadSize = SizePage };
               VirtualCollectionPays.ItemsLoading += VirtualCollectionPays_ItemsLoading;
               
               PayDataPage datapager = null;
                
               var slowTask = Task.Run(() =>
               {
                   datapager = _dataProvider.GetQueryableLazyPay(SizePage, position, PayFilterDescriptor, PaySortDescriptor, PayGroupDescriptor);
               });
     
               await slowTask;
     
               VirtualCollectionPays.VirtualItemCount = datapager.TotalCount;
               VirtualCollectionPays.Load(0, datapager.DataItems);
           }


     
    async void VirtualCollectionPays_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
            {
                 
                BusyIndicatorGrid = true;
                try
                {
                    PayDataPage datapager = null;
                    ItemsLoading = Task.Run(() =>
                    {
                        datapager = _dataProvider.GetQueryableLazyPay(SizePage, e.StartIndex, PayFilterDescriptor, PaySortDescriptor, PayGroupDescriptor);
                    });
     
                    await ItemsLoading;
                     
                    VirtualCollectionPays.Load(e.StartIndex, datapager.DataItems);
                     
                    BusyIndicatorGrid = false;
                }
                catch (Exception ex)
                {
                    string mg = ex.Message;
                }
     
            }

    when selected change of gridView the scrollbar change position 

    void radGridViewPay_SelectionChanged(object sender, SelectionChangeEventArgs e)
           {
               var VMListePay = this.DataContext as VMListePay;
               radGridViewPay.ScrollIndexIntoView(VMListePay.VirtualCollectionPays.CurrentPosition);
            
           }


    same problem when i change SelectionChanged with PropertyChanged

    void VirtualCollectionPays_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
           {
               var VMListePay = this.DataContext as VMListePay;
               if (e.PropertyName == "CurrentPosition")
               {
                   if (VMListePay.VirtualCollectionPays.CurrentPosition >= 0)
                   {
                       radGridViewPay.ScrollIndexIntoView(VMListePay.VirtualCollectionPays.CurrentPosition);
                   }
     
               }
           }










  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 17 Mar 2015 Link to this post

    Hello,

    I have just replied in the other thread you opened on the same topic.

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top