Skip to content

How to skip the sorting when group the columns in WinForms DataGrid (SfDataGrid) ?

Notifications You must be signed in to change notification settings

SyncfusionExamples/how-to-skip-the-sorting-when-group-the-columns-in-uwp-data-grid

Repository files navigation

How to Skip the Sorting When Group the Columns in UWP DataGrid?

This sample illustrates how to skip the sorting when group the columns in UWP DataGrid (SfDataGrid).

By default, DataGrid groups a column in the sorted order. However, you can group a specific column in the actual order without sorting the groups in SfDataGrid by removing the grouped column from the SfDataGrid.View.SortDescriptions.

C#

this.dataGrid.Loaded += OnDataGrid_Loaded;

private void OnDataGrid_Loaded(object sender, RoutedEventArgs e)
{
    this.dataGrid.View.CurrentChanged += OnView_CurrentChanged;
}

private void OnView_CurrentChanged(object sender, object e)
{
    var groupColumn = dataGrid.View.SortDescriptions.FirstOrDefault(x => x.PropertyName == "ProductName");

    if (dataGrid.SortColumnDescriptions.FirstOrDefault(x => x.ColumnName == "ProductName") != null)
        dataGrid.View.SortDescriptions.Remove(groupColumn);
}

Grouping a column without applying sorting for it

Requirements to run the demo

Visual Studio 2015 and above versions

About

How to skip the sorting when group the columns in WinForms DataGrid (SfDataGrid) ?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages