Hi,
I'm trying to use grouping feature of xamdatagrid. I would like to do initial default grouping by three fields and then allow user to rearrange or group accordingly as he wishes. Is that something that is possible? I'm using ListCollectionView and SortEvaluationMode = 'UseColllectionView'
Thanks
Hello RJ,
In order to initially group the XamDataGrid when using a collection view, I would recommend that you add a new PropertyGroupDescription to the GroupDescriptions collection of your ListCollectionView. Note, in order for this to work correctly, you will also need to set the GroupEvaluationMode property of your XamDataGrid.FieldLayoutSettings to "UseCollectionView." This essentially delegates the grouping work back to the collection view that is used as the DataSource of your XamDataGrid.
As an alternative, you can go without setting the UseCollectionView setting in this case, and add new FieldSortDescription elements to your XamDataGrid FieldLayout's SortedFields collection. You can read further about doing this here: https://es.infragistics.com/help/wpf/xamdatapresenter-sorting-and-grouping-fields-programmatically.
I have attached a sample project to demonstrate the initial ListCollectionView grouping operation. I hope this helps.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Hi Andrew,
Thanks for the prompt reply. I'm using the FieldLayout SortedFields collection to add the grouping. But, one thing I noticed is that when I sort on a field, the expanded grid is collapsing. Is there a way to sort without collapsing? can I customize the header display? Can I give styling to the group headers?
Thanks,
The sample that you provided the day before, when you click number to sort, it is collapsing the groups. the behavior is not the same in the new sample that you provided yesterday.
I noticed that the sort behavior is happening only when the GroupEvaluationMode is set to "useCollectionView" and sort on the field that is not used in grouping.
As far as the styling is concerned, thanks for the info but if I want to style the field headers in the groupbyarea section, how to achieve that?
Thank you for your update on this matter.
The field headers in the group-by-area section are LabelPresenter elements, and so I would recommend that if you wish to style them, you write a style for that element. Note, though, that this LabelPresenter element type is the same element type that is used for the actual Field headers in the rest of the XamDataGrid. If you only wish to style the LabelPresenters that exist in the group-by-area and leave the other headers alone, I would recommend you first write a Style for GroupByAreaMulti and add your LabelPresenter style to the Style.Resources section of this style. This would look like the following:
<Style TargetType="{x:Type igDP:GroupByAreaMulti}"> <Style.Resources> <Style TargetType="{x:Type igDP:LabelPresenter}"> </Style> </Style.Resources></Style>
I have attached a modified version of the sample project I had last sent you to demonstrate the above.
Regarding the collapsing behavior, I have reproduced the behavior in which the groups collapse when sorting. It appears you are correct in that this happens when GroupByEvaluationMode is set to "UseCollectionView", although it appears that SortEvaluationMode needs to have this setting as well. I am also only seeing this behavior when there are multiple group descriptions in the underlying ListCollectionView.
This is unexpected behavior, and as such I have reached out to our engineering staff to examine this further. To ensure it receives attention, I have logged this issue in our internal tracking system with a development ID of 242731. I have also created a private support case for you so that you can track this issue. It has an ID of CAS-187265-G9N4G9 and you can access it at https://es.infragistics.com/my-account/support-activity. I will be sending an update to it shortly with more details on the link to this development issue.
Thank you for the response.
Couple of more things,
I'm trying to disable the grouping only for certain fields and allow grouping for the rest. Can I achieve that?
For summaries, can we display the summary in the group headers, above the field that is used for summary, without the label like "Sum" ?
Also, if we want to display only few summary fields only on a particular group and not display on other groups, is that possible? this is for a 4 level hierarchy.