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
60
Refresh UltraGrid’s GroupBy Sort on child bands when ListChanged?
posted

Hello, 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); ?