Bug with string column filtering

3 posts, 0 answers
  1. Joel
    Joel avatar
    78 posts
    Member since:
    Oct 2012

    Posted 12 Jun 2012 Link to this post

    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. Grahame
    Grahame avatar
    10 posts
    Member since:
    Feb 2013

    Posted 29 Apr 2014 Link to this post

    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>();

    //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));
  3. Grahame
    Grahame avatar
    10 posts
    Member since:
    Feb 2013

    Posted 29 Apr 2014 in reply to Grahame Link to this post

    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>();
    request.Filters = (IList<IFilterDescriptor>)filterDescriptions;

    //to this:

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

Back to Top