This is a migrated thread and some comments may be shown as answers.

Filter doesn't work with generic class

1 Answer 111 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Valentin
Top achievements
Rank 1
Iron
Valentin asked on 01 Oct 2019, 03:41 PM

Hi Telerik,

 

I'mu using a base class with all proerties which are overridable :

Public Class SelectionDetailItemViewModel
        Inherits ViewModelBase
 
        Public Overridable Property Children As New ObservableCollection(Of SelectionDetailItemViewModel)
        Public Overridable Property Reference As String
        Public Overridable Property Name As String
 
        'Other properties .....

 

I have 2 classes A & B which inherit of SelectionDetailItemViewModelA class has children of type of A & B.

The ItemSource is bound to a ObservableCollection(Of SelectionDetailItemViewModel). For each column, the filter panel has all column values but select a value doesn't filter the RadTreeListView. There the following error :

System.Windows.Data Error: 8 : Cannot save value from target back to source. BindingExpression:Path=IsActive; DataItem='DistinctValueViewModel' (HashCode=63240628); target element is 'CheckBox' (Name=''); target property is 'IsChecked' (type 'Nullable`1') ArgumentException:'System.ArgumentException: La valeur "((Name IsEqualTo er 2d2 MC)) AND ((Name IsEqualTo <Unset>) AND (Name IsEqualTo <Unset>))" n'est pas de type "Telerik.Windows.Data.IFilterDescriptor" et ne peut pas être utilisée dans cette collection générique.
Nom du paramètre : value
   à System.ThrowHelper.ThrowWrongValueTypeArgumentException(Object value, Type targetType)
   à System.Collections.ObjectModel.Collection`1.System.Collections.IList.Insert(Int32 index, Object value)
   à Telerik.Windows.Data.CollectionHelper.Insert(IList target, IEnumerable newItems, Int32 startingIndex, IEqualityComparer itemComparer)
   à Telerik.Windows.Data.ObservableCollectionManager.HandleCollectionChanged(IList sender, NotifyCollectionChangedEventArgs args)
   à Telerik.Windows.Data.ObservableCollectionManager.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
   à Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
   à System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   à System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   à Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   à Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   à System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
   à Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
   à Telerik.Windows.Data.FilterDescriptorCollection.InsertItem(Int32 index, IFilterDescriptor item)
   à System.Collections.ObjectModel.Collection`1.Add(T item)
   à Telerik.Windows.Controls.GridViewColumn.OnColumnFilterDescriptorPropertyChanged(Object sender, PropertyChangedEventArgs e)
   à Telerik.Windows.Data.DescriptorBase.OnPropertyChanged(PropertyChangedEventArgs args)
   à Telerik.Windows.Data.DescriptorBase.OnPropertyChanged(String propertyName)
   à Telerik.Windows.Data.DescriptorBase.ResumeNotifications()
   à Telerik.Windows.Controls.GridView.FilteringViewModel.ApplyFilters()
   à Telerik.Windows.Controls.GridView.FilteringViewModel.OnDistinctValuesChanged()
   à Telerik.Windows.Controls.GridView.FilteringViewModel.OnDistinctValuesItemChanged(Object sender, ItemChangedEventArgs`1 e)
   à Telerik.Windows.Data.ObservableItemCollection`1.RaiseGenericItemChanged(ItemChangedEventArgs`1 e)
   à Telerik.Windows.Data.ObservableItemCollection`1.OnItemChanged(ItemChangedEventArgs`1 e)
   à Telerik.Windows.Data.ObservableItemCollection`1.Telerik.Windows.Data.IWeakEventListener<System.ComponentModel.PropertyChangedEventArgs>.ReceiveWeakEvent(Object sender, PropertyChangedEventArgs args)
   à Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
   à System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
   à Telerik.Windows.Controls.ViewModelBase.OnPropertyChanged(String propertyName)
   à Telerik.Windows.Controls.GridView.DistinctValueViewModel.set_IsActive(Boolean value)'

 

Have you got any idea ?

Thanky you.

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 04 Oct 2019, 12:16 PM

Hello Valentin,

There are couple of issues here. The first one is that RadTreeListView doesn't supported showing objects of different types. This leads to unexpected behaviors. Instead, you will need to use the same data type.

The second issue is that there a bug in RadGridView which is the control that is inherited by RadTreeListView.

To work this around, you can use a single business model showing all the information from objects A and B. Or you can implement custom filtering and sorting

I hope this information helps. If you have other questions, please let me know.

Regards,
Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TreeListView
Asked by
Valentin
Top achievements
Rank 1
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or