How to update the summaries when a row is dragged and dropped between groups in Xamarin.Forms ?
Grouping and summaries of items in Xamarin DataGrid are manipulated based on a group key. When you drag and drop an item from one group to another group, the group key of the dragged item will differ from the group key of the items in the dropped group. Hence by default the summaries will not be updated. This is the actual behavior of SfDataGrid.
Hence, in order to update the summaries when a row is dragged and dropped between groups you need to call the UpdateCaptionSummaries and Refresh methods in the QueryRowDragging event.
MainPage.cs
public partial class MainPage : ContentPage { private SfDataGrid dataGrid; private ViewModel viewModel; public MainPage() { InitializeComponent(); dataGrid = new SfDataGrid(); viewModel = new ViewModel(); dataGrid.ItemsSource = viewModel.OrdersInfo; dataGrid.QueryRowDragging += DataGrid_QueryRowDragging; this.Content = dataGrid; } private async void DataGrid_QueryRowDragging(object sender, QueryRowDraggingEventArgs e) { if (e.Reason == QueryRowDraggingReason.DragEnded) { // Delay is given for refreshing the view. await Task.Delay(100); this.dataGrid.View.TopLevelGroup.UpdateCaptionSummaries(); this.dataGrid.View.Refresh(); } }
Screenshot:
Sample Link: How to update the summaries if row drag and drop performed between groups?
I hope you enjoyed learning about how to update the summaries when a row is dragged and dropped between groups in Xamarin Forms.
You can refer to our Xamarin Grid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!