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
50
Programmatically set grouping
posted

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.

Parents
  • 78
    posted

    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
                                                                        });
    }


     

Reply Children