RadGridView filter using wildcards

6 posts, 1 answers
  1. Michal Zámec
    Michal Zámec avatar
    5 posts
    Member since:
    May 2010

    Posted 03 Jun 2011 Link to this post

    Hi,

    I'm trying to use FilterDescriptors.Expression in radgrid, but everytime i put any wildcard here, it always wraps that wildcard into brackets (name like 'a%' became name like 'a[%]') and grid gets fully filtered, because there is no matching line. I've tried diferent types of wildcards (*, %, ?) but it always gets me the same result. Am I missing something? 

    Thanks
  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 05 Jun 2011 Link to this post

    Hello,

    Please take a look at the documentation for filters here (simple or composite).

    If i understood correcly and you are adding filters programmaticaly you should just specify the Operator corresponding to your required filter, possible operator values are : IsLike, IsNotLike, IsLessThan, IsLessThanOrEqualTo, IsEqualTo, IsNotEqualTo, IsGreaterThanOrEqualTo, IsGreaterThan, StartsWith, EndsWith, Contains, NotContains, IsNull,  IsNotNull, IsContainedIn, IsNotContainedIn.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Michal Zámec
    Michal Zámec avatar
    5 posts
    Member since:
    May 2010

    Posted 06 Jun 2011 Link to this post

    I've already tried FilterDescriptors, but the behavior was the same. Every wildcard inserted in text (value) was escaped and wrapped into brackets []. Then I tried to use that FilterDescriptors.Expression in order to bypass that behavior, but no success at all. I just need to somehow tell the grid to filter for example: name like 'ab%cd%'

    Any ideas?
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 06 Jun 2011 Link to this post

    Hello again,

    Ok, maybe i was not clear enough, the only way to do this is to create a composite filter, for your case you will need something like this:
    CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
    compositeFilter.FilterDescriptors.Add(new FilterDescriptor("Name", FilterOperator.StartsWith, "ab"));
    compositeFilter.FilterDescriptors.Add(new FilterDescriptor("Name", FilterOperator.Contains, "cd"));
    compositeFilter.LogicalOperator = FilterLogicalOperator.And;
    this.radGridView1.FilterDescriptors.Add(compositeFilter);

    So here, you want all the Name's starting with ab (ab%) AND all names containing cd (%cd%) right?

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  6. Michal Zámec
    Michal Zámec avatar
    5 posts
    Member since:
    May 2010

    Posted 06 Jun 2011 Link to this post

    So there is no way, I can put wildcards into radgrid filtering? Composite descriptors will work in most cases, but they'll fail for something like this: name like '%ab%cd%'. By using FIlterDescriptors (contains('ab') AND contains('cd')), its not desired behavior ('abcd' is ok, but 'cdab' will also pass that condition, which is wrong)

    EDIT: If I get it right, FilterDescriptors.IsLike and FilterDescriptors.IsNotLike does not work/is not implemented yet? Because those descriptors should be exactly what i need, but still, they wont accept wildcards.
  7. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 09 Jun 2011 Link to this post

    Hello Michal,

    Thank you for writing.

    Unfortunately, we do not support specifying a wildcard character in the filter criteria even if the Like operator is used. The wildcard is always escaped and there is not an elegant work-around for the situation. We will consider improving this functionality for one of the next releases.

    Let me know if you have any other questions.

    Best wishes,
    Martin Vasilev
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Back to Top
UI for WinForms is Visual Studio 2017 Ready