I am trying to alter the meber name of a filterdescriptor but get error Unable to cast object of type 'Kendo.Mvc.CompositeFilterDescriptor' to type 'Kendo.Mvc.FilterDescriptor' here
If request.Filters.Any(Function(y) CType(y, Kendo.Mvc.FilterDescriptor).Member.Equals("FranchiseeName")) Then
Dim filter As FilterDescriptor = CType(request.Filters.Single(Function(g) CType(g, Kendo.Mvc.FilterDescriptor).Member.Equals("FranchiseeName")), FilterDescriptor)
filter.Member = "Franchisee.Name"
I don't know what the difference is or why I get this, I have done simular before without this problem.
1 Answer, 1 is accepted
answered on 12 Dec 2014, 08:49 AM
There are two concreate implementation of IFilterDescriptor - the CompositeFilterDescriptor and the FilterDescriptor. CompositeFilterDescriptor class is required as the filters can be complex - multiple filters with And or Or logic. Therefore, usually the FilterDescriptors are nested within an instance of CompositeFilterDescriptor. Therefore in order to iterate over the filters you will need to conditionally navigate to through the CompositeFilterDescriptor's FilterDescriptors property. Similar to the following: