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 can I disable grouping in SfDataGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

118671 Mar 31,2015 01:57 AM Apr 1,2015 02:32 PM WPF 1
loading
Tags: SfDataGrid
Andreas Söllner
Asked On March 31, 2015 01:57 AM

I want to toggle grouping in SfDataGrid on an off.

Is there something better?
This code makes the columns to resize, in some cases to width = 0.

if (Grid.GroupColumnDescriptions.Count > 0)

{

   Grid.GroupColumnDescriptions.Clear();

}

else

{

   foreach (var droupDescription in listPropertyGroupDescription)

   {

                        var group = new GroupColumnDescription()

                        {

                            ColumnName = droupDescription.PropertyName

                        };

                       

                        Grid.GroupColumnDescriptions.Add(group);

   }

}


Jai Ganesh S [Syncfusion]
Replied On April 1, 2015 02:32 PM

Hi Andreas,

 

Thank you for using Syncfusion products.

 

We have analyzed your query and we need more information on your requirement. Based on your title, you can disable the grouping by set AllowGrouping as false. If you would like to add and remove the groups at runtime like toggle the group on or off on specific column by below code snippet,

 

Code Snippet [C#]:

 

private void Button_Click(object sender, RoutedEventArgs e)

 {

                     if (sfdatagrid.GroupColumnDescriptions.Any())

                            sfdatagrid.GroupColumnDescriptions.Clear();

                    else

                            sfdatagrid.GroupColumnDescriptions.Add(new GroupColumnDescription() { ColumnName = "ProductName" });

  }

 

 

We have also prepared the sample based on this and please find the sample under the following location,

 

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/136396/SfDataGroupingDemo-553868901.zip

 

If we misunderstood your requirement, could you please let us know, what you are trying to achieve from your code snippet and in which case column width will be 0. Please share the more details about your query. This would be more helpful for us to serve you in better way.

 

Please let us know if you need further assistance.

 

Thank you,

Jai Ganesh S


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

;