How do I programmatically set the grouping for fields. I want to be able to not expose the groupby area on the grid but have buttons outside of the grid that perform specific grouping.
Grouping information is contained in the SortedFields collection as part of the FieldLayout. Once a sort has been added though, you can not change it so you will need to remove it and add a new instance.
if (!XamDataGrid1.FieldLayouts[0].SortedFields.Contains("Market Price")) {
XamDataGrid1.FieldLayouts[0].SortedFields.Add(new FieldSortDescription { FieldName = "Market Price", IsGroupBy= true });
}else{ XamDataGrid1.FieldLayouts[0].SortedFields.Remove(XamDataGrid1.FieldLayouts[0].SortedFields["Market Price"]); XamDataGrid1.FieldLayouts[0].SortedFields.Add(new FieldSortDescription { FieldName = "Market Price", IsGroupBy = true });}
mmihevc said: Grouping information is contained in the SortedFields collection as part of the FieldLayout. Once a sort has been added though, you can not change it so you will need to remove it and add a new instance. if (!XamDataGrid1.FieldLayouts[0].SortedFields.Contains("Market Price")) { XamDataGrid1.FieldLayouts[0].SortedFields.Add(new FieldSortDescription { FieldName = "Market Price", IsGroupBy= true }); }else{ XamDataGrid1.FieldLayouts[0].SortedFields.Remove(XamDataGrid1.FieldLayouts[0].SortedFields["Market Price"]); XamDataGrid1.FieldLayouts[0].SortedFields.Add(new FieldSortDescription { FieldName = "Market Price", IsGroupBy = true });}
Are we sure this actually works? Intellisense does not confirm the presence of ".SortedFields". While converting to VB, I can not make this example work at all. I am using the Express version, and I suppose it is possible that is the issue. Can anyone confirm?
yepp, it works, thx for posting