views:

1482

answers:

1

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

A: 

Sounds like a bug to me - you should file one with Infragistics.

As to a workaround - this is not a nice solution and I haven't tested it but you could always try saving the sort-by (group) columns to a temp store, RefreshSort() on the band, then re-apply the sort-by (gorup) columns, and sort again?

ie. Remove group-by, then re-apply.

Nasty, but it might get you out of a bind.

Mark Allanson