We use the following code to put a filter on tree items which work great intially.
snip .....
TreeListView.FilterDescriptors.SuspendNotifications();
ClearFilters();
ApplyFilter(Reflector.GetProperty<ProjectReleaseLineViewModel>((line) => line.HasError).Name, true, FilterOperator.IsEqualTo);
snip ......
private void ClearFilters()
{
foreach (var column in TreeListView.Columns.OfType<Telerik.Windows.Controls.GridViewBoundColumnBase>())
{
var filterControl = column.FilteringControl as ColumnFilterControl;
if (filterControl != null)
{
filterControl.Reset(column);
}
}
}
private void ApplyFilter(string member, object value, FilterOperator @operator = FilterOperator.IsEqualTo)
{
var filter = new CompositeFilterDescriptor();
filter.FilterDescriptors.Add(new FilterDescriptor(member, @operator, value));
var colum = TreeListView.Columns.OfType<GridViewBoundColumnBase>().Skip(2).First();
colum.DataControl.FilterDescriptors.Add(filter);
}
When performing this action the tree explands showing the lines which have errors.
The strange behaviour happens after that through the following actions.
- The use manually collapses the expanded items al the way to level zero
- Then the filter is cleared through the following code