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

Bug with string column filtering

2 Answers 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Joel asked on 12 Jun 2012, 07:38 AM
Message: Exception: System.InvalidCastException: Unable to cast object of type 'Kendo.Mvc.CompositeFilterDescriptor' to type 'Kendo.Mvc.FilterDescriptor'.
   at Kendo.Mvc.Infrastructure.Implementation.FilterNodeVisitor.Visit(PropertyNode propertyNode)
   at Kendo.Mvc.Infrastructure.Implementation.OrNode.Accept(IFilterNodeVisitor visitor)
   at Kendo.Mvc.UI.DataSourceRequestModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
   at System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor)
   at System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)

2 Answers, 1 is accepted

Sort by
0
Grahame
Top achievements
Rank 2
answered on 29 Apr 2014, 04:45 PM
I am also having this issue, I am trying to tack on a new composite filter within my ASP MVC Controller.

public ActionResult BizObjList_Read([DataSourceRequest]DataSourceRequest request)
{
List<int> userProjects = new List<int>(){1,2,3,4,5,8,27,689}; // I use different code so ignore this part
Kendo.Mvc.CompositeFilterDescriptor validUserProjects = new CompositeFilterDescriptor();
validUserProjects.LogicalOperator = FilterCompositionLogicalOperator.Or;
validUserProjects.FilterDescriptors.AddRange(userProjects.Distinct().Select(x =>  new Kendo.Mvc.FilterDescriptor("ProjectID",FilterOperator.IsContainedIn,x)));
List<Kendo.Mvc.CompositeFilterDescriptor> filterDescriptions = new List<CompositeFilterDescriptor>();
filterDescriptions.Add(validUserProjects);

//This errors but I can't do it without a cast
request.Filters = (IList<IFilterDescriptor>)filterDescriptions;
//This is my DB lookup using the Kendo ToDataSourceResult to build my SQL query.
return Json(DataService.GetBizObj().ToDataSourceResult(request));
}
0
Grahame
Top achievements
Rank 2
answered on 29 Apr 2014, 04:55 PM
Ok, issue was I as trying to assign a list and should have used the .Add() syntax to put my filter on.

//Changed this:
List<Kendo.Mvc.CompositeFilterDescriptor> filterDescriptions = new List<CompositeFilterDescriptor>();
filterDescriptions.Add(validUserProjects);
request.Filters = (IList<IFilterDescriptor>)filterDescriptions;

//to this:
request.Filters.Add(validUserProjects);

Things look to be working better now, my other errors do not seam related.







Tags
Grid
Asked by
Joel
Top achievements
Rank 1
Answers by
Grahame
Top achievements
Rank 2
Share this question
or