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
135
XamDataGrid - column groupings not indicated in the GroupByAreaMulti
posted

I've got a grid that I've applied a grouping to - by setting the FieldLayout's SortedFields.

See example code below.

The SortedFields are applied correctly - can see that the groupings are applied in the grid, but on clicking the expander, can't see any of the groupings in the group by area. If you then click on column "Test 2" to sort by it, then "Test 1" grouping appears in the group by area.

I think it's an ordering issue

1) Set DataSource 2) Set Fields 3) Set SortedFields - works fine

1) Set DataSource 2) Set SortedFields 3) Set Fields - the symptoms above occur

1) Set SortedFields 2) Set DataSource 3) Set Fields - the symptoms above occur

1) Set Fields 2) Set SortedFields 3) Set DataSource - works fine

 

The docs for 12.1 say that when populating SortedFields, if the field is not present then an exception is thrown. I can't seem to find any docs saying that's the case for 14.1, an exception isn't thrown, but the current behavior isn't 100% if the SortedFields are set before the Fields are populated.

(Sorry for the formatting - I don't have permission to upload attachments, and I can't see an option to paste code in your editor - the formatting should be OK if copy and paste into Visual Studio)

 

MainWindow.xaml:

     <igWPF:XamDataGrid x:Name="grid">         <igWPF:XamDataGrid.FieldLayoutSettings>             <igWPF:FieldLayoutSettings AutoGenerateFields="False"                                        HeaderPlacementInGroupBy="OnTopOnly"></igWPF:FieldLayoutSettings>         </igWPF:XamDataGrid.FieldLayoutSettings>         <igWPF:XamDataGrid.FieldSettings>             <igWPF:FieldSettings AllowEdit="False" CellClickAction="SelectCell" AllowGroupBy="True" />         </igWPF:XamDataGrid.FieldSettings>     </igWPF:XamDataGrid>

 

MainWindow.xaml.cs:

    public partial class MainWindow     {         public MainWindow()         {             InitializeComponent();

            Loaded += MainWindow_Loaded;         }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)         {             SetDataSource();

            SetSortedFields();

            SetFields();         }

        private void SetFields()         {             if (grid.DefaultFieldLayout == null)             {                 grid.FieldLayouts.Add(new FieldLayout());             }

            // NOTE: This line is necessary for the sorted fields to be applied if set             //  before fields             grid.DefaultFieldLayout.Fields.Clear();

            grid.DefaultFieldLayout.Fields.Add(                 new Field                     {                         Name = "Test1",                         Label = "Test 1"                     });

            grid.DefaultFieldLayout.Fields.Add(                 new Field                     {                         Name = "Test2",                         Label = "Test 2"                     });         }

        private void SetSortedFields()         {             if (grid.DefaultFieldLayout == null)             {                 grid.FieldLayouts.Add(new FieldLayout());             }

            grid.DefaultFieldLayout.SortedFields.BeginUpdate();             grid.DefaultFieldLayout.SortedFields.Add(                 new FieldSortDescription("Test1", ListSortDirection.Ascending, true));             grid.DefaultFieldLayout.SortedFields.EndUpdate();         }

        private void SetDataSource()         {             grid.DataSource = new List<ItemVm>                 {                     new ItemVm {Test1 = "A", Test2 = 1.0},                     new ItemVm {Test1 = "B", Test2 = 2.0},                     new ItemVm {Test1 = "A", Test2 = 3.0},                 };         }     }

    public class ItemVm     {         public string Test1 { get; set; }         public double Test2 { get; set; }     }

 

 

 

 

Parents Reply Children