
I have a grouping action event (see below) that fires when as a user I drop a column into the grouping area. I also get the action event when I close the group. However, when I create the group descriptor pro-grammatically (see below) the action event does not fire but the group displays properly. When I close the group pro-grammatically created group I get the action event but the program crashes. What am i missing?
private void CreateGroup_Click(object sender, RoutedEventArgs e)
{
GroupDescriptor descriptor = new GroupDescriptor();
descriptor.Member = "CategoryName";
descriptor.SortDirection = ListSortDirection.Ascending;
this.gridQueryResult.GroupDescriptors.Add(descriptor);
descriptor = new GroupDescriptor();
descriptor.Member = "ProductName";
descriptor.SortDirection = ListSortDirection.Ascending;
this.gridQueryResult.GroupDescriptors.Add(descriptor);
}
private void gridQueryResult_Grouping(object sender, GridViewGroupingEventArgs e)
{
Telerik.Windows.Controls.GridViewColumn column = ((ColumnGroupDescriptor)e.GroupDescriptor).Column;
if (e.Action == GroupingEventAction.Place)
{
if (column != null)
column.IsVisible = false;
}
else if (e.Action == GroupingEventAction.Remove)
{
if (column != null)
column.IsVisible = true;
}
}
9 Answers, 1 is accepted
Actually, that would be the expected behavior. Grouping/Grouped events will be fired only when performing the action on the UI, not when inserting a new group descriptor in the GroupDescriptors collection.
What is the exact behavior that you want to achieve and why do you need it fired on adding a group descriptor programmatically ?
Maya
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>

Hi Maya,
I want to accomplish two things.
When the user closes the app I want to save the group descriptions so the next time the user runs the query I can reestablish the groupings. When I reestablish the groupings I want the Group column set to visible is false. (I want to see the column in the group but not in the detail section.
If and when the User closes the Group thru the UI I want to set the column back to visible. I am getting this event but it crashes in my event logic (see from previous post). Why does this crash happen. There must be something else I need to setup. When creating the Group from the UI there must be something done that I an not doing when I create the group from the program.
It my program did not crash in the event logic everything would be ok.
Thanks
Rich
Saving the state of the grid can be performed with the help of RadPersistenceFramework. Check out our demos for more information. Considering the second issue, why not setting ShowColumnWhenGrouped property of the column to "false" ?
Maya
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>

Hi Maya,
The demo asked me to install Silverlight and then didn't like my version of Internet explorer. I am using Windows 8.1 and I guess its IE is not able to handle Silverlight. I could turn of some security functions but I rather not if possible. Is there any other way to run the demo.
Thanks
Rich
You can work with your own local copy of our demos. WPF demos can be installed from here as well. Let me know in case you find any issues with running the examples.
Maya
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>

Hi Maya
I am using wpf RadGridView and do not seem to have the ShowColumnWhenGrouped property. Is that a Silverlight only thing.
Rich

Hi Maya
I referred to the Demo for WPF Persistence Manager Gridview and found that I could not compile the following:
private void OnSave(object sender, System.Windows.RoutedEventArgs e)
{
PersistenceManager manager = new PersistenceManager();
this.stream = manager.Save(this.gridView);
}
In order to get PersistenceManager recognized I had to add Using OpenAccessRuntime.
new PersistenceManager() failed because its an abstact class
manager.Save.......... Save not in PersistenceManager
Thanks
Rich
ShowColumnWhenGrouped is a property of the column, not the grid. You can take a look at our documentation for more information.
Considering the second question, you do not need OpenAccessRuntime using. The required usings are listed in the example mentioned above and there are:
using Telerik.Windows.Persistence;
using Telerik.Windows.Persistence.Services;
using Telerik.Windows.Controls;
Do you still have compilation errors when you add those ?
Regards,
Maya
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>

Hi Maya,
I am using the those using statements. What I did not have was a reference to Telerik.Persistence.Manager. Since I did not get an error with the Persistence using statements I thought I did not need to reference an assembly. I have a reference to the OpenAccess assembly and maybe that's why my using statements did not have an error or maybe I just don't understand how this all works.
Thanks
Rich