I am loading a large datasource into a XamDataGrid and in the FieldLayoutInitialized event handler I'm defining some SummaryDefinition based on Property Attributes.
foreach (var columnDetailsAttribute in attributes.Where(attribute => attribute.TotalsBy || attribute.AverageBy)){ var summaryDefinition = new SummaryDefinition(); summaryDefinition.SourceFieldName = columnDetailsAttribute.PropertyName; summaryDefinition.Calculator = columnDetailsAttribute.TotalsBy ? (SummaryCalculator) Infragistics.Windows.DataPresenter.SummaryCalculator.Sum : Infragistics.Windows.DataPresenter.SummaryCalculator.Average; e.FieldLayout.SummaryDefinitions.Add(summaryDefinition);}
this works fine.
However I would like to turnoff or not define the SummaryDefinition if the grouping only has one group.
Hello ahrensd,
Thank you for the provided sample application.
I have been looking into it and have modified it for you.
In the modified sample application I am checking if the second group has one item in it. If it has I clear the SortedFields collection. In order to preserve the first grouping( by the 'Name' Field) I assign the grouping manually after the SortedFields collection is cleared.
Please find the attached sample application and feel free to let me know if you have any further questions on this matter.
Have updated your code, I want to disable grouping on a field if the result will give 1 item in each group as happens with grouping LastItem
pic https://cloudstor.aarnet.edu.au/plus/public.php?service=files&t=b8faa73c0670d18cf55d336916687525
Thank you for the provided information.
I have been looking into your issue. In order to remove the groups that have only one item in them you can set the visibility of the GroupByRecord to Collapsed.
I have created a small sample application for you to show you this functionality. In the sample application I have a simple XamDataGrid bound to a collection. Then if you group by the "Age" field you would be able to see that there are only two groups.
Please note, that when you group by more than one field you would have to loop through the children of the second group to check the count of the items in them.
here is a screen shot, it turns out very messy with the grouping not doing anything but add confusion. would be great if the control could deal with this.
I don't want the grouping for that field to be applied.