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

any/all operators for filtering using DataSourceRequest - many to many

1 Answer 264 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
leblanc
Top achievements
Rank 1
leblanc asked on 04 May 2013, 06:49 AM
I have an Alert DataSource i have a listview bound to.
Alerts many to many with Tags
I need a way to filter using the any operator.  Is this supported in: DataSourceRequest?

how would i define the json if supported or is there a workaround?
{
     "field": "Tags",
                    "operator": "eq",
                   "value": 'Marketing'
}



related:
http://stackoverflow.com/questions/9278044/wcf-data-services-many-to-many-with-filter

1 Answer, 1 is accepted

Sort by
0
leblanc
Top achievements
Rank 1
answered on 07 May 2013, 04:05 PM
doesn't seem to be supported in DataSourceRequest .  So going move to use the wcf data services odata version.


namespace Kendo.Mvc.Extensions
{
    using System.Collections.Generic;
    using Kendo.Mvc.Infrastructure.Implementation;
     
    public static class FilterTokenExtensions
    {
        private static readonly IDictionary<string, FilterOperator> tokenToOperator = new Dictionary<string, FilterOperator>
        {
            { "eq", FilterOperator.IsEqualTo },
            { "neq", FilterOperator.IsNotEqualTo },
            { "lt", FilterOperator.IsLessThan },
            { "lte", FilterOperator.IsLessThanOrEqualTo },
            { "gt", FilterOperator.IsGreaterThan },
            { "gte", FilterOperator.IsGreaterThanOrEqualTo },
            { "startswith", FilterOperator.StartsWith },
            { "contains", FilterOperator.Contains },
            { "notsubstringof", FilterOperator.DoesNotContain },
            { "endswith", FilterOperator.EndsWith },
            { "doesnotcontain", FilterOperator.DoesNotContain }
        };
 
        private static readonly IDictionary<FilterOperator, string> operatorToToken = new Dictionary<FilterOperator, string>
        {
            { FilterOperator.IsEqualTo, "eq" },
            { FilterOperator.IsNotEqualTo, "neq" },
            { FilterOperator.IsLessThan, "lt" },
            { FilterOperator.IsLessThanOrEqualTo, "lte" },
            { FilterOperator.IsGreaterThan, "gt" },
            { FilterOperator.IsGreaterThanOrEqualTo, "gte" },
            { FilterOperator.StartsWith, "startswith" },
            { FilterOperator.Contains, "contains" },
            { FilterOperator.DoesNotContain,"notsubstringof" },
            { FilterOperator.EndsWith, "endswith" }
        };

By the way - this whole manual parser could be more easily expressed with: https://github.com/leblancmeneses/NPEG
Tags
Data Source
Asked by
leblanc
Top achievements
Rank 1
Answers by
leblanc
Top achievements
Rank 1
Share this question
or