I'm using the GroupDescriptors property in XAML to define the grid to group rows. I.e. the rows are grouped using one column.
Why is the grouped column still visible when I start the application? When I ungroup and the group again using mouse, the column is then hidden. Not very consistent. Is this a bug or am I missing a property here?
You can test this issues with your SDK Samples Browser application. Just open the GridView->Group Selection example in Visual Studio, set ShowColumnWhenGrouped property to false for the first GridViewDataColumn object, and run the example. For simplicity, you may also want to comment out the second GroupDescriptor object in the GroupDescriptors collection. I.e. use just one column to group like I do.
6 Answers, 1 is accepted
I did some digging around and it looks like GroupDescriptor isn't working correctly.
I created my own class that derives from RadGridView class. I had to use ColumnGroupDescriptor class and check in RadGridView.Columns.CollectionChanged event handler when to column count is 2 (the first column is the indexer column or whatever) and then add new ColumnGroupDescriptor object to the GroupDescriptors collection. ColumnGroupDescriptor does not have Member property, but it has Column property. That's why the above.
Anyways, this surely isn't the recommended way to handle the situation. It's even harder to use the ColumnGroupDescriptor approach in XAML.
Am I doing something wrong with the GroupDescriptor approach, or is this a bug?
Also, not sure if this a bug or a feature, but if you define a style for GridViewDataColumn (i.e. ShowColumnWhenGrouped = False), and put it in RadGridView's Resources, the Resources element has to be before the Columns element.
I.e. the order matters. Not 100% if this is how XAML is parsed by the system, but FYI at least.
[quote]J said:Also, if I set GroupDescriptor.SortDirection in RadGridView.Grouped event handler, I cannot change the group sorting in UI with mouse. I.e. clicking the group box in the group area to sort the rows.[/quote]
Ok, scratch that. Just realized that you can check the value of e.Action. I.e. I can now change the the sort order nicely, but the original issues still stands.
Indeed in order for the ShowColumnWhenGrouped property to be reflected in the UI, you can use a ColumnGroupDescriptor. You can check out the Column ShowColumnWhenGrouped thread in our forum where a similar topic was discussed.
Additionally, defining a ColumnGroupDescriptor in xaml isn't hard at all. Can you check out the Programmatic Grouping article in our documentation which demonstrates how you can achieve this?
On a side note, please do keep in mind that it is not recommended to define styles targeting RadGridView columns since they are not visual elements and this could lead to potential issues.
I hope you find this helpful.
Regards,
Vladimir Stoyanov
Progress Telerik