Articles in this section
Category / Section

How to create the single group for null and empty value in WPF DataGrid (SfDataGrid)?

1 min read

An empty and null values are created the separate groups in WPF DataGrid (SfDataGrid). You can able to create the single group for empty and null value by using Converter in GroupColumnDescription.

dataGrid.GroupColumnDescriptions.Add(new GroupColumnDescription() { Converter = new GroupStringNullConverter(), ColumnName = "CustomerName" });
 
 
public class GroupStringNullConverter: IValueConverter
{
    public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
    {
        var customerName = value as OrderInfo;
 
        if (string.IsNullOrEmpty(customerName.CustomerName))
            return null;
        else
            return customerName.CustomerName;
    }
 
    public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture)
    {
        throw new System.NotImplementedException();
    }
}

 

Grouping SfDataGrid

View sample in GitHub

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