Home Forums WPF controls Xceed DataGrid for WPF Update Grouping On Data Change

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26279 |

    I have a Status enum in the class I’m displaying in a DataGridCollectionView, and they essentially represent states of a statemachine, but with different paths. Waiting can go to Cancelled, Cancelled can go back to Waiting, Failed can go to Waiting, etc. From the users perspective its basically a toggle, but I didn’t want a checkbox. So, I implemented a Button:

    <xcdg:CellEditor>
    <xcdg:CellEditor.EditTemplate>
    <DataTemplate>
    <Button
    Content=”{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=xcdg:DataCell}, Path=ParentRow.DataContext.ToggleText}”
    Click=”toggleAnalysisStatus_Click”
    />
    </DataTemplate>
    </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>

    with this as the event handler

    private void toggleAnalysisStatus_Click(object sender, RoutedEventArgs e)
    {
    if (this.tlist.CurrentItem == null)
    return;

    DataRow row = this.tlist.GetContainerFromItem(this.tlist.CurrentItem) as DataRow;

    if (row != null)
    {
    CalGroupItem item = row.DataContext as CalGroupItem;
    if (item != null)
    item.ToggleStatus();
    row.EndEdit();
    //(tlist.ItemsSource as DataGridCollectionView).Refresh();
    }
    }

    The problem is that if I group by AnalysisStatus, then toggle an item’s AnalysisStatus, the edited row doesn’t re-position to its new group.

    If I uncomment the Refresh line above, it does update the grouping, but its not speedy and looses the collapsed state of other groups. Is there another function I can call to get it updated more specifically?

    Thanks

    Imported from legacy forums. Posted by Thomas (had 2047 views)

    Xceed Support
    Member
    Post count: 5658

    I will assume that you are not using version 2.0 since the state of the groups is preserved as of that version. That said, other than calling Refresh, which also has the side effect of losing the expansion state of groups (as you experienced), there is no other method to update the grouping manually.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 2913 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.