Hi,
I'm aware you can set a grouping level programtically, by adding a FieldSortDescription. I'm also aware you can use FieldSettings to control the "AllowGroupBy" property.
This *nearly* works well! I run the project, expand the group by area and see the grid has correctly been grouped by "Name". The three fields for which I've allowed gropuing, appear below.
However, the grid allows me to drag the "Name" grouping (which I was trying to force as 'always on'), to the bottom section... when I do so, the grid un-groups and the "Name" button in the group by area disappears!
Is this incorrect behaviour? Or is there any way to control it that I've missed?
Regards,
Dave
Hello Dave,
I am not completely sure if this is the correct behavior of the XamDataGrid. If you have set AllowGroupBy to false globally and then explicitly just set AllowGroupBy only to Type, Category 1 and Category 2 , then this is expected, as the Name would have AllowGroupBy false and will disappear.
I believe I did something like this in the forum, but cannot seem to find it right now, but :
Creating a style for the GroupByFieldLabel and using a DataTrigger with Binding Field.Name and Value Name (in your case) and setting the Visibility property to Collapsed would do the trick.
<Style TargetType="{x:Type igDP:GroupByFieldLabel}">
<Style.Triggers>
<DataTrigger Binding="{Binding Field.Name}" Value="Name">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
Hi Alex,
Your suggestion worked great in prior releases, but now the latest version is using GroupByAreaMultiPanel objects, it no longer works.
Have you got any ideas how I could achieve this in v9.2? I had a quick look but couldn't see any easy way to get to "Field.Name"....
Cheers,
Dave,
This is an "only under XP" issue. I should have probably tested it under XP as well as under Vista.
I am going to create a support case on your behalf.
-Alex
Hey Alex,
Thanks for the suggestion - that style appears to be exactly what I want - however, it's doing strange things....
...so, I've updated my demo app (please find attached).
Without the style, you can apply groupings and everything appears ok:
I've added your style to "Doc1.xaml", for the "department" field (it programatically groups by this field when loaded). The idea being we want to force the department grouping, users should be able to apply additional groupings on top of this one, but they should not be able to remove the department grouping at all.
The style does have the effect of hiding the "department" LabelPresenter when in the group by area, but it also has a couple of strange side effects. The style of any additional LabelPresenters in the group by area loose their background and the style of all the standard LabelPresenters in the header row get messed up:
I'm really not sure what's going on here as that style should surely only be affecting the department field!?
Hey Dave,
How about this:
<Style TargetType="{x:Type igDP:LabelPresenter}">
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsInGroupByArea, RelativeSource={RelativeSource Self}}" Value="True"/>
<Condition Binding="{Binding Field.Name, RelativeSource={RelativeSource Self}}" Value="Name"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
</MultiDataTrigger.Setters>
</MultiDataTrigger>