SFDataGrid - Pull to refresh works only once on Android

Hi,
I have been struggling for a bit to get pull to refresh datagrid work properly on Android. It works great on iOS but works only once on Android and then stops. Could you please check and advise as I suspect I might not have implemented it correctly.
Thanks,
kunal

3 Replies

DY Deivaselvan Y Syncfusion Team October 19, 2018 01:03 PM UTC

Hi Kunal, 

Thanks for contacting Syncfusion Support.

We checked your query “PullToRefresh works only once on Android”. We prepared the sample for enabling refreshing in SfDataGrid and refreshing works fine in Android platform.

Please find the code snippet below for implementing PullToRefresh in SfDataGrid. You need to set the SfDataGrid.AllowPullToRefresh as true and set the SfDataGrid.PullToRefreshCommand. You need to set the SfDataGrid.IsBusy as true before start refreshing and SfDataGrid.IsBusy as false after refreshing, which is highlighted in the RefreshItems command. 
 
//MainPage.xaml  
<ContentPage.BindingContext>  
  <local:ViewModel x:Name="viewModel" />  
</ContentPage.BindingContext>  
<ContentPage.Content>  
  <sfgrid:SfDataGrid x:Name="sfGrid"  
           AutoGenerateColumns="False"  
           ItemsSource="{Binding OrdersInfo}"  
           AllowPullToRefresh="True"  
           PullToRefreshCommand ="{Binding Refresh}"  
           IsBusy="{Binding Busy}"  
           >  
    <sfgrid:SfDataGrid.Columns>  
      <sfgrid:GridTextColumn MappingName="OrderID" />  
      <sfgrid:GridTextColumn MappingName="EmployeeID" />  
      <sfgrid:GridTextColumn MappingName="CustomerID" />  
      <sfgrid:GridTextColumn MappingName="ShipCountry" HeaderText="Country"/>  
    </sfgrid:SfDataGrid.Columns>  
  </sfgrid:SfDataGrid>  
</ContentPage.Content>  
 
public class ViewModel : NotificationObject  
{  
    public Command Refresh { get; set; }  
  
    private bool busy;  
    public bool Busy  
    {  
        get  
        {  
            return busy;  
        }  
  
        set  
        {  
            busy = value;  
            RaisePropertyChanged("Busy");  
        }  
    }  
  
    public ViewModel()  
    {  
        order = new OrderInfoRepository();  
        random = new Random();  
        Refresh = new Command(RefreshItems);  
        SetRowstoGenerate(50);  
    }  
  
    private async void RefreshItems()  
    {  
        this.Busy = true;  
        await Task.Delay(new TimeSpan(0, 0, 5));  
        ItemsSourceRefresh();  
        this.Busy = false;  
    }  
  
    public void ItemsSourceRefresh()  
    {  
        int count = random.Next(1, 6);  
  
        for (int i = 11000; i < 11000 + count; i++)  
        {  
            int value = i + random.Next(100, 150);  
            this.OrdersInfo.Insert(0, order.GenerateOrder(value));  
        }  
    }  
 

We have attached the sample prepared for your reference. 
 

For more details on PullToRefresh in SfDataGrid, refer the below UG link. 
 

Regards,
Deivaselvan 



KU Kunal October 22, 2018 07:12 PM UTC

Thanks Deivaselvan. The demo project has been very helpful. I have got it working now.

Kunal


VR Vigneshkumar Ramasamy Syncfusion Team October 23, 2018 06:11 AM UTC

 
Hi Kunal, 
 
Thanks for the update. We glad to know that customer requirement has been achieved. Please get in touch if you required further assistance on this. 
   
Regards 
Vigneshkumar R 


Loader.
Up arrow icon