Refresh UltraGrid's GroupBy Sort on child bands when ListChanged?
Posted
by Idriss
on Stack Overflow
See other posts from Stack Overflow
or by Idriss
Published on 2009-08-13T10:26:43Z
Indexed on
2010/05/11
5:04 UTC
Read the original article
Hit count: 1216
I am using Infragistics 2009 vol 1.
My UltraGrid is bound to a BindingList of business objects "A" having themself a BindingList property of business objects "B". It results in having two bands: one named "BindingList`1", the other one "ListOfB" thanks to the currency manager.
I would like to refresh the GroupBy sort of the grid whenever a change is performed on the child band through the child business object and INotifyPropertyChange.
If I group by a property in the child band which is a boolean (let's say "Active") and I subscribe to the event ListChanged on the bindinglist datasource with this event handler:
void Grid_ListChanged(object sender, ListChangedEventArgs e)
{
if (e.ListChangedType == ListChangedType.ItemChanged)
{
string columnKey = e.PropertyDescriptor.Name;
if (e.PropertyDescriptor.PropertyType.Name == "BindingList`1")
{
ultraGrid.DisplayLayout.Bands[columnKey].SortedColumns.RefreshSort(true);
}
else
{
UltraGridBand band = ultraGrid.DisplayLayout.Bands[0];
UltraGridColumn gc = band.Columns[columnKey];
if (gc.IsGroupByColumn || gc.SortIndicator != SortIndicator.None)
{
band.SortedColumns.RefreshSort(true);
}
ColumnFilter cf = band.ColumnFilters[columnKey];
if (cf.FilterConditions.Count > 0)
{
ultraGrid.DisplayLayout.RefreshFilters();
}
}
}
}
the band.SortedColumns.RefreshSort(true) is called but It gives unpredictable results in the groupby area when the property Active is changed in the child band:
if one object out of three actives becomes inactive it goes from:
- Active : True (3 items)
To:
- Active : False (3 items)
Instead of (which is the case when I drag the column back and forth to the group by area)
Active : False (1 item)
Active : True (2 items)
Am I doing something wrong?
Is there a way to restore the expanded state of the rows when performing a RefreshSort(true); ?
© Stack Overflow or respective owner