We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to customize Group header when user add a column to the group area

Hello

I want to allow user to group data using a column binded to a enum value.
I can define a default grouping but if user removes the column and adds it again, the header formating is lost

            <syncfusion:SfDataGrid.SortComparers>
                <data:SortComparer Comparer="{StaticResource customSortComparer}" PropertyName="MeasureTypeEnum" />
            </syncfusion:SfDataGrid.SortComparers>
            <syncfusion:SfDataGrid.GroupColumnDescriptions>
                <syncfusion:GroupColumnDescription ColumnName="MeasureTypeEnum" Converter="{ StaticResource customGroupConverter }"/>
            </syncfusion:SfDataGrid.GroupColumnDescriptions>

Any way to make the default column description always set ?

Thank you


1 Reply

AR Akila Rajaram Syncfusion Team July 11, 2014 06:23 AM UTC

Hi Pierre,

We have analyzed your query. You can achieve your requirement by handling GroupDescriptions.CollectionChanged event and setting Converter for the column that is going to be grouped at runtime.

Please refer the following code snippet,

Code snippet:

public MainWindow()

        {

            InitializeComponent();

            this.sfGrid.ItemsSourceChanged += sfGrid_ItemsSourceChanged;

        }

void sfGrid_ItemsSourceChanged(object sender, GridItemsSourceChangedEventArgs e)

        {

            this.sfGrid.View.GroupDescriptions.CollectionChanged += GroupDescriptions_CollectionChanged;

        }

void GroupDescriptions_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)

        {

            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)

            {

                if ((e.NewItems[0] as PropertyGroupDescription).PropertyName == "Date")

                {

                    (e.NewItems[0] as PropertyGroupDescription).Converter = new GroupDataTimeConverter();

                }

            }

        }

 

Please let us know if you have any queries.

Regards,

Akila


Attachment: GroupingDemo_23f39528.zip

Loader.
Live Chat Icon For mobile
Up arrow icon