Articles in this section

How to apply sorting for the new items added in .NET MAUI DataGrid (SfDataGrid)?

Sorting can be applied to new items added in .NET MAUI DataGrid by setting the LiveDataUpdateMode property to AllowDataShaping.

xaml:
<Grid RowDefinitions="*,50">
  <syncfusion:SfDataGrid  x:Name="dataGrid" 
                          ItemsSource="{Binding Employees}"
                          Grid.Row="0"
                          AutoGenerateColumnsMode="None"
                          LiveDataUpdateMode="AllowDataShaping"
                          SortingMode="Single"
                          DefaultColumnWidth="155">
      <syncfusion:SfDataGrid.Columns>
          <syncfusion:DataGridTextColumn MappingName="EmployeeID"
                                         HeaderText="Employee ID" />
          <syncfusion:DataGridTextColumn MappingName="Name"
                                         HeaderText="Name" />
          <syncfusion:DataGridTextColumn MappingName="IDNumber"
                                         HeaderText="ID Number" />
      </syncfusion:SfDataGrid.Columns>

  </syncfusion:SfDataGrid>
  <Button Clicked="Button_Clicked"
          WidthRequest="200"
          HorizontalOptions="Start"
          Margin="80,0,0,3"
          Grid.Row="1"
          Text="Add Item" />
</Grid>

xaml.cs:
private void Button_Clicked(object sender, EventArgs e)
{
  viewModel.Employees.Add(new Employee()
  {
      EmployeeID = "1002",
      Name = "Sean Jacobson",
      IDNumber = 99,
      ContactID = 199,
      ManagerID = 2,
      LoginID = "sean2",
      Gender = "Male",
      Title = "GM",
      MaritalStatus = "Single",
      HireDate = new DateTime(2023, 01, 03),
      BirthDate = new DateTime(2023, 01, 03),
      SickLeaveHours = 14,
      Salary = 5999,
      EmployeeStatus = true,
      Rating = 1,
  });
}

Executing the code example above yields the following output.

Download the complete sample from GitHub.

Conclusion

I hope you enjoyed learning how to apply sorting for new items added in .NET MAUI DataGrid (SfDataGrid).

You can refer to our .NET MAUI DataGrid feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI DataGrid Documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components on the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to explore our .NET MAUI DataGrid and other .NET MAUI components.

Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac or feedback portal, or the feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied