This is a migrated thread and some comments may be shown as answers.

[Solved] How to ungroup columns in Grid via code

5 Answers 206 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tushar Mehere
Top achievements
Rank 1
Tushar Mehere asked on 04 Nov 2009, 03:10 AM
Hi,

I am displaying a Grid with table1 records. The same grid is used to display table2 records on selection from a tables dropdown.
My code works fine. It throws up when i group a column from table1 and then select table2 from the dropdown and try to bind the grid again.

I need a way to ungroup columns programmatically before rebinding with another table.

Thanks,
Tushar

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 04 Nov 2009, 06:08 AM
Hello Tushar,

You can remove desired GroupDescriptor from GroupDescriptors. Check this demo for more info:
http://demos.telerik.com/silverlight/beta/#GridView/HeaderContextMenu

All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tushar Mehere
Top achievements
Rank 1
answered on 04 Nov 2009, 06:16 AM
Thanks for responding.

However, my question was how do i ungroup the grouped columns using c#. The demo links describe it in xaml.

In my project code i wrote

GroupDescriptorCollection disCol = this.Mygrid.GroupDescriptors;
disCol=null;
//bind grid
this did not work for me. let me know if i am missing something.

Appreciate your help.

Tushar





0
Vlad
Telerik team
answered on 04 Nov 2009, 06:18 AM
Hi Tushar,

You've missed header context menu implementation - check the code behind "Ungroup" menu item click.

All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tushar Mehere
Top achievements
Rank 1
answered on 04 Nov 2009, 07:17 PM
Thanks you very much. Yes i missed the link you sent.

I resolved my issue of ungrouping all columns dynamically with the following code:

foreach(Telerik.Windows.Data.GroupDescriptor gd in this.myGrid.GroupDescriptors)
                {
                    if(gd!=null)
                        this.myGrid.GroupDescriptors.Remove(gd);
                }

Thanks once again.

Tushar
0
Milan
Telerik team
answered on 05 Nov 2009, 06:53 AM
Hello Tushar Mehere,

You could also try " this.myGrid.GroupDescriptors.Clear()" to remove all group descriptors at once.


Sincerely yours,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Tushar Mehere
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Tushar Mehere
Top achievements
Rank 1
Milan
Telerik team
Share this question
or