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
180
XamDataGrid's Grouping and Grouped events don't occur
posted

Hi,

I've found a very strange thing in XamDataGrid in connection with its grouping behaviour.
(I've created a simple sample and I've attached it to this post.)
The problem is the following. When I use the default controls to group the records by one of the fields the Grouping and Grouped events occur properly. But for example if I group by code those events don't occur.

Run my sample and try this:
Open the group header and click one of the buttons above it. The group header will be changed and the records will be grouped but the events will not be fired. After it abolish the grouping by pulling down the sorted field and see that those events will be fired.

The code:

<Window x:Class="XamDataGridEditor.Window1"
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
Title="Window1" Height="300" Width="300" xmlns:igDP="http://infragistics.com/DataPresenter">
<StackPanel>
   <StackPanel Orientation="Horizontal">
      <Button Content="Group by PropertyName" Click="ButtonPropertyName_Click" />
      <Button Content="Group by PropertyValue" Click="ButtonPropertyValue_Click" />
   </StackPanel>
   <igDP:XamDataGrid Name="xamDataGrid1" />
</StackPanel>
</
Window>

 public Window1()
{
InitializeComponent();

List
<BLLObject> bllSource = new List<BLLObject>();
bllSource.Add(
new BLLObject("Row1", "x"));
bllSource.Add(
new BLLObject("Row2", "y"));
xamDataGrid1.DataSource = bllSource;

xamDataGrid1.Grouped +=
new EventHandler<GroupedEventArgs>(xamDataGrid1_Grouped);
xamDataGrid1.Grouping +=
new EventHandler<GroupingEventArgs>(xamDataGrid1_Grouping);
}

void xamDataGrid1_Grouping(object sender, GroupingEventArgs e)
{
Console.WriteLine("xamDataGrid1_Grouping occurs");
}

void xamDataGrid1_Grouped(object sender, GroupedEventArgs e)
{
Console.WriteLine("xamDataGrid1_Grouped occurs");
}

private void ButtonPropertyName_Click(object sender, RoutedEventArgs e)
{
xamDataGrid1.FieldLayouts[0].SortedFields.Clear();

FieldSortDescription sort = new FieldSortDescription();
sort.Direction =
ListSortDirection.Descending;
sort.FieldName =
"PropertyName";
sort.IsGroupBy =
true;

xamDataGrid1.FieldLayouts[0].SortedFields.Add(sort);
}

private void ButtonPropertyValue_Click(object sender, RoutedEventArgs e)
{
xamDataGrid1.FieldLayouts[0].SortedFields.Clear();

FieldSortDescription sort = new FieldSortDescription();
sort.Direction =
ListSortDirection.Descending;
sort.FieldName =
"PropertyValue";
sort.IsGroupBy =
true;

xamDataGrid1.FieldLayouts[0].SortedFields.Add(sort);
}

I think this is not normal.
Have anybody seem that before? I would be glad if anybody had any suggestions.

Best regards,
atus

XamDataGrid_v82_group.zip
  • 138253
    Offline posted

    Hello Atus,

    Thank you for your post. I have been looking through it and I can say that this is normal, because our controls doesn’t fire their events if the action is done by code. If so, you can execute the desired code after the action you perform. This is like a pattern for custom controls, which is used to have better performance. Please note, we are making efforts to ensure all posts are addressed by an Infragistics expert. We believe that the other community members could benefit from this thread as well.

    Feel free to write me if you need further assistance.