Combining grid filters

2 posts, 0 answers
  1. Tim
    Tim avatar
    4 posts
    Member since:
    Sep 2008

    Posted 11 Aug 2015 Link to this post

    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?

     

  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 13 Aug 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top