Hi,
We allow our users to select columns by which to group a grid. We need to save their choice so as to be able to re-instate it later (automatically).
Could you please let me know how to programmatically (C#) retrieve columns by which a XamGrid is currently grouped, and also how to programmatically group that grid by some columns? I would really appreciate if you could provide code samples for both cases.
Thank you.
Best regards,
Adam
Hello Adam,
Thank you for your feedback. I am glad that you have managed to resolve your issue.
Hi Yanko,
Thank you for your suggestions. I managed to develop a solution using Fields and SortedFields collections in each layout of grid.FieldLayouts, and the field attributes Direction and IsGroupBy.
Thanks for your help.
Regards,
I am just checking if you require any further assistance on the matter.
I have been looking into your questions and you can get the columns by which the XamGrid is currently grouped by getting the ‘GroupByColumns’ collection like e.g. :
List<Column> groupByColumns = this.xamGrid1.GroupBySettings.GroupByColumns.ToList();
You can set the GroupByColumns in code like e.g. :
Column col1 = this.xamGrid1.Columns.DataColumns[0];
Column col2 = this.xamGrid1.Columns.DataColumns[1];
this.xamGrid1.GroupBySettings.GroupByColumns.Add(col1); // first approach
col2.IsGroupBy = true; // second approach
Let me know, if you need any further assistance on this matter.