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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

116943 Jul 7,2014 03:11 PM UTC Jul 11,2014 06:23 AM UTC WPF 1
loading
Tags: SfDataGrid
Pierre-Alain GALTIER
Asked On July 7, 2014 03:11 PM UTC

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


Akila Rajaram [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;