Dear forums,
Right now I have a grid (2010.2.714.40) that uses the DefaultView of a DataTable as an ItemsSource. Unfortunately using something other than DataTables in not an option in my scenario. I have a custom IFilterDescriptor which lets me filter the grid based on some complicated rules. The filter works when it is applied, but if the data in the row changes, the filter is not reapplied. Looking at this forum post it seems like that is the expected behavior. Regardless, I need it to work the other way. The alternatives suggested in that thread are not viable in my situation because it is too expensive to recreate/reset the collection view (thus reapplying the filter on each row) every time a field changes. Are there any other alternatives?
My idea for a workaround was to add a layer of abstraction between the data table and the ItemsSource and do the filtering there instead of using the Grid's built in filtering. This is doable because the filters are created outside of the Grid's filtering UI. My FilteredCollectionView class took the DataTable as a member, and listened for changes to the table. With each row change event it applied the filter on the modified row, and added/removed the DataRow as necessary to an ObservableCollection<DataRow>. I then set the Grid's ItemsSource to that ObservableCollection.
Sadly this is not working as expected. Whenever I try to use my collection, I get errors like these for each column: Property <PropertyName> not defined for type DataRow at Telerik.Windows.Data.PropertyPathDescriptor.GetPropertyDescriptor(PropertyToken token, Type componentType).
I suspect it is occurring because of the dynamic nature of DataTables/DataRows and how the grid deals with them internally; it probably knows how to handle DataRows when the ItemsSource is a DataTable, but it never expects to see DataRows in a normal collection.
Any solutions to my current workaround, or suggestions of other workarounds will be greatly appreciated.
Thanks,
Tom
Right now I have a grid (2010.2.714.40) that uses the DefaultView of a DataTable as an ItemsSource. Unfortunately using something other than DataTables in not an option in my scenario. I have a custom IFilterDescriptor which lets me filter the grid based on some complicated rules. The filter works when it is applied, but if the data in the row changes, the filter is not reapplied. Looking at this forum post it seems like that is the expected behavior. Regardless, I need it to work the other way. The alternatives suggested in that thread are not viable in my situation because it is too expensive to recreate/reset the collection view (thus reapplying the filter on each row) every time a field changes. Are there any other alternatives?
My idea for a workaround was to add a layer of abstraction between the data table and the ItemsSource and do the filtering there instead of using the Grid's built in filtering. This is doable because the filters are created outside of the Grid's filtering UI. My FilteredCollectionView class took the DataTable as a member, and listened for changes to the table. With each row change event it applied the filter on the modified row, and added/removed the DataRow as necessary to an ObservableCollection<DataRow>. I then set the Grid's ItemsSource to that ObservableCollection.
Sadly this is not working as expected. Whenever I try to use my collection, I get errors like these for each column: Property <PropertyName> not defined for type DataRow at Telerik.Windows.Data.PropertyPathDescriptor.GetPropertyDescriptor(PropertyToken token, Type componentType).
I suspect it is occurring because of the dynamic nature of DataTables/DataRows and how the grid deals with them internally; it probably knows how to handle DataRows when the ItemsSource is a DataTable, but it never expects to see DataRows in a normal collection.
Any solutions to my current workaround, or suggestions of other workarounds will be greatly appreciated.
Thanks,
Tom