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

Combining grid filters

1 Answer 27 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 11 Aug 2015, 08:44 AM

Hi,

I am trying to write a filter that produces the following :-

SELECT *
FROM [MyTable]
WHERE
(
    ([StartDate] >= @StartDate AND [EndDate] <= @EndDate )
    OR
    ([EndDate] >= @StartDate AND [EndDate] <= @EndDate )
    OR
    ([StartDate] <= @StartDate AND [EndDate] >= @EndDate )
)
AND ([Status] = @Status)

All attempts so far have failed, could anyone please help?

 

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 13 Aug 2015, 06:29 AM

Hello Tim,

We have already answered your question in the support ticket you have open on this. I'm pasting the response for completeness.

This should look similar to the following:

dataSource.filter({
  logic: "and",
  filters: [
    {
      logic: "or",
      filters: [
        {
          logic: "and",
          filters: [
            { field: "StartDate", operator: "gte", value: new Date(/*..*/) },
            { field: "EndDate", operator: "lte", value: new Date(/*..*/) }
          ]
        },
        {
          logic: "and",
          filters: [
            { field: "StartDate", operator: "gte", value: new Date(/*..*/) },
            { field: "EndDate", operator: "lte", value: new Date(/*..*/) }
          ]
        },
        {
          logic: "and",
          filters: [
            { field: "StartDate", operator: "gte", value: new Date(/*..*/) },
            { field: "EndDate", operator: "lte", value: new Date(/*..*/) }
          ]
        }
      ]
    },
    {
      logic: "or",
      filters: [
          { field: "Status", operator: "eq", value: "SOMEVALUE" },
          { field: "Status", operator: "eq", value: "All" }
      ]
    }
  ]
});
Basically, every brackets expression is a composite expression with a logic operator and the value expressions are the leaves.

 

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
Tim
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or