How to remove and clear entire records from SfDataGrid?

I'm using SfDataGrid in Xamarin forms and I want to clear the entire records from the SfDataGrid. Basically, I want to make the grid empty again. How can I do that in C#?

1 Reply

AN Ashok N Syncfusion Team July 14, 2017 06:12 AM UTC

Hi Gangatharan, 

Thanks for contacting Syncfusion support. 

You can achieve your requirement by clearing the Binding ItemsSource. Please refer the below code example : 

<ContentPage.BindingContext> 
    <local:ViewModel x:Name="viewModel" /> 
</ContentPage.BindingContext> 

<sfgrid:SfDataGrid x:Name="dataGrid"  
            ItemsSource="{Binding OrdersInfo}" > 
</sfgrid:SfDataGrid> 

private void ClearRecords_Clicked(object sender, EventArgs e) 
{ 
    // Clear the records from view 
    viewModel.OrdersInfo.Clear(); 
} 


Regards, 
Ashok 


Loader.
Up arrow icon