Using the generated filter text

2 posts, 0 answers
  1. Scott
    Scott avatar
    4 posts
    Member since:
    Nov 2010

    Posted 14 Nov 2010 Link to this post

    I'm just getting started with Telerik controls.  My question has to do with the RadDataFilter.  I have a need to build a complex search query that I will then submit to an existing service to get the results I need. 

    Since I need to send the resulting query text to a service, I have nothing to bind the Filter control to for the Source.  I want the user to enter the words they are interested in, and the AND, OR, NOT operators to end up with something like this:

    (("word1" AND "word2") OR ("word3" AND "word4") AND NOT ("Bad Word"))

    Is this possible with the DataFilter?


  2. Rossen Hristov
    Rossen Hristov avatar
    2478 posts

    Posted 15 Nov 2010 Link to this post

    Hello Scott,

    You have two options.

    In case you need the string in a specific format, you can easily build it yourself by traversing the FilterDescriptors collection of the control. The logical operator property of this collection is in fact the root node of a tree of filter criteria. The collection consists of filter descriptors -- they can be either simple ones (member-operator-value) or composite ones. The composite ones are filter descriptors that contain other filter descriptors and have a logical operator, i.e. they provide the hierarchy. So you can traverse this tree in the order that you want and build the string.

    Out-of-the-box, if you call the ToString method of the FilterDescriptors collection it will return a similar string, but chances are it will not be 100% the format that you need to build. Anyway, try this and see what will come out.

    I hope this helps. Let me know if you have problems.

    Sincerely yours,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top