admin管理员组

文章数量:1313347

Our application is using Kendo for UI, for fetching Data from backend it is using filter operators. now I want to fetch data with complex filter as in the below code, I want to filter for the DueDate field >= condition and other thing is, it should be complex like the condition is "TaskGroupStatus is Pending or Rejected and DueDate field >= CurrentDate", like in 3 paramters 2 should be with or condition and 3rd parameter is applied as and on top of the other paramters, how to frame this filter in the below code? Is it possible, need some help. Thank you so much

DataQueryParameters queryParameters = new DataQueryParameters();
queryParameters.Filter = new Filter()
{
    Logic = "or",
    Filters = new List<Filter>()
    {
        new Filter()
        {
            Field = "TaskGroupStatus",
            Operator = "eq",
            Value =  (int)TaskGroupStatus.Pending
        },
        new Filter()
        {
            Field = "TaskGroupStatus",
            Operator = "eq",
            Value = (int)TaskGroupStatus.Rejected
        },
        new Filter()
        {
            Field = "DueDate",
            Operator = "gte",
            Value =  (int)TaskGroupStatus.Pending
        }
    }
};

Our application is using Kendo for UI, for fetching Data from backend it is using filter operators. now I want to fetch data with complex filter as in the below code, I want to filter for the DueDate field >= condition and other thing is, it should be complex like the condition is "TaskGroupStatus is Pending or Rejected and DueDate field >= CurrentDate", like in 3 paramters 2 should be with or condition and 3rd parameter is applied as and on top of the other paramters, how to frame this filter in the below code? Is it possible, need some help. Thank you so much

DataQueryParameters queryParameters = new DataQueryParameters();
queryParameters.Filter = new Filter()
{
    Logic = "or",
    Filters = new List<Filter>()
    {
        new Filter()
        {
            Field = "TaskGroupStatus",
            Operator = "eq",
            Value =  (int)TaskGroupStatus.Pending
        },
        new Filter()
        {
            Field = "TaskGroupStatus",
            Operator = "eq",
            Value = (int)TaskGroupStatus.Rejected
        },
        new Filter()
        {
            Field = "DueDate",
            Operator = "gte",
            Value =  (int)TaskGroupStatus.Pending
        }
    }
};
Share Improve this question edited Jan 30 at 22:08 AbdulAleem asked Jan 30 at 20:09 AbdulAleemAbdulAleem 6310 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Filters can be nested. If you want "(TaskGroupStatus is Pending or Rejected) and DueDate field >= CurrentDate", your top level logic is "and" with the first filter having the two nested filters with logic as "or".

DataQueryParameters queryParameters = new DataQueryParameters();
queryParameters.Filter = new Filter()
{
    Logic = "and",
    Filters = new List<Filter>()
    {
        new Filter()
        {
            Logic = "or",
            Filters = new List<Filter>()
            {
                new Filter()
                {
                    Field = "TaskGroupStatus",
                    Operator = "eq",
                    Value =  (int)TaskGroupStatus.Pending
                },
                new Filter()
                {
                    Field = "TaskGroupStatus",
                    Operator = "eq",
                    Value = (int)TaskGroupStatus.Rejected
                }
            }
        },
        new Filter()
        {
            Field = "DueDate",
            Operator = "gte",
            Value =  (int)TaskGroupStatus.Pending
        }
    }
};

本文标签: cKendo operators for Complex logic mix of lt or gt and combiningStack Overflow