Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1336
Is it possible to force a grouping?
posted

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.

  1. I want to force our grid to be grouped by "Name" - so I've added a FieldSortDescription in code for this field. 
  2. There are lots of columns and it wouldn't make sense to group by most of them, so I've set the main FieldSettings.AllowGroupBy to False.
  3. We do however want the end user to be able to optionally apply further grouping levels, but only for fields "Type", "Category 1" and "Category 2"  (by way of example).  So, I've set the AllowGroupBy to true, on the FieldSettings for just these three fields.

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

Parents
No Data
Reply
  • 69686
    posted

    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>

Children