Programmatically building a Composite Filter

3 posts, 1 answers
  1. Helen
    Helen avatar
    101 posts
    Member since:
    Nov 2008

    Posted 29 Mar 2011 Link to this post

    I'm having a problem trying to programmatically build a filter for the following situation, on a RadDomainDataSource.

    The filter .ANDs a filter based on FK guid (department_uid) with another Composite Filter which ORs 2 filters on text comparing the first letters of FirstName and LastName fields.

    Another wrinkle is that the Guid comes from a comboBox, and I have added an extra item "All" to its ItemsSource in which case the user does not want to filter by the FK relationship.

    It works fine when I just use the Composite filter for FirstName & LastName.

    When I create another CompositeFilter which includes the above CompositeFilter and try to add the filter for the Guid, I have to put Guid.Empty for the initial value, or it errors out with a type error. That results in all the records being filtered out. I tried using a string type for the filter, and converting the Guid to a string in the ComboBox's selectionchanged event, but that errors out too.

    Any suggestions?

    Could I suggest that you change the RadDataFilter in the future to allow nullable types, and to allow the user to specify a default value for don't filter?

    Thanks

    Helen
  2. Answer
    Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 31 Mar 2011 Link to this post

    Hi Helen,

    There is a special singleton value for "don't filter" called FilterDescriptor.UnsetValue. When you create a FilterDescriptor which Value is equal to FilterDescriptor.UnsetValue it will be totally ignored by the data engine. It will be like you have never added it in the first place.

    I hope this helps.

    Kind regards,
    Ross
    the Telerik team
  3. DevCraft banner
  4. Helen
    Helen avatar
    101 posts
    Member since:
    Nov 2008

    Posted 31 Mar 2011 Link to this post

    YES! Exactly what I needed! Nice & clean!

    RadDomainDataSource rocks!!!
Back to Top