Ticket T1062743
Visible to All Users

How to construct a hierarchical filtering expression

created 3 years ago (modified 3 years ago)

[DevExpress Support Team: CLONED FROM T707120: How to filter data with DataSourceLoadOptions on the server]

What is the javascript for the filter Array's PUSH order when you want to AND two sets of ORs.

For this to work, the ORs should be grouped together in order for the AND to apply to different sets of ORs. But just pushing parenthesis and/or brackets leads to an EXCEPTION.

SO, HOW IS THIS DONE ??

(

['Color', '=', 'Red']
or
['Color', '=', 'Blue']

)

AND

(

['Size', '=', 'Large']
or
['Size', '=', 'Small']

)

Answers approved by DevExpress Support

created 3 years ago

Hi Brian,

A hierarchical filtering expression can be defined as an array of arrays. For example:
[ [ ["a", "=", 5], "or", ["a", "=", 6] ], "and", ["b", "=", 3] ]

Please refer to Group Filter Operations to find more info on this syntax.

    Show previous comments (2)

      Artem,

      ALMOST. The code I posted is COPIED from your earlier example. It only uses ONE column and all is 'OR's.

      Can you create a filter with TWO columns?
      an OR within each column but an AND between columns as in this construct:

      [ — I tried this but pushing this initial bracket led to an EXCEPTION
      [
      ['Color', '=', 'Red']
      **or **
      ['Color', '=', 'Blue']
      ]
      AND
      [
      ['Size', '=', 'Large']
      **or **
      ['Size', '=', 'Small']
      ]
      ]

      Andrew Ser (DevExpress Support) 3 years ago

        Hello Brian,
        I modified Artem's sample to demonstrate how to build a filter similar to what you posted: Updated CodePen. Select two rows and click the "Test Filter" button to test the filter.
        If it doesn't help, please modify our sample to demonstrate your usage scenario and the issue you encounter. Currently, it is unclear how you are using filters and what exception you see.

          Thanks.  I’ll give that a try.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.