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

recursive loading data when scrolling (virtualCollection)

1 Answer 84 Views
GridView
This is a migrated thread and some comments may be shown as answers.
nidhal ben hamadou
Top achievements
Rank 1
nidhal ben hamadou asked on 12 Mar 2015, 02:40 PM
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);
               }
 
           }
       }










1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 17 Mar 2015, 11:51 AM
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.

 
Tags
GridView
Asked by
nidhal ben hamadou
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or