Default Filter Function for Custom Field Editor

7 posts, 1 answers
  1. Campus Labs
    Campus Labs avatar
    13 posts
    Member since:
    Jan 2007

    Posted 25 Oct 2010 Link to this post

    As described in my previous post, I've created a custom field editor for the RadFilter and restricted the available filter functions in the filter menu. The available functions are Contains, DoesNotContain, IsEmpty, and NotIsEmpty. When the editor is first created, however, the default filter function selected is EqualTo - even though EqualTo is not allowed in the menu. I've attached a screenshot where you can see EqualTo is selected even though it isn't in the list of available filter functions.

    I'm guessing that since I'm hiding the filter menu items client-side, the RadFilter doesn't know that EqualTo is not a valid selection for a filter function when creating the new field editor server-side. How can I change the default filter function for my custom field editor to be Contains instead of EqualTo?
  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 29 Oct 2010 Link to this post

    Hi Ross,

    In order to overcome that issue for the filter expressions added manually, you need to create a different type of expression but RadFilterEqualToFilterExpression<T> expression for the particular column.
    Check it out and let me know if this works for you.

    Kind regards,
    Iana
    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. UI for ASP.NET Ajax is Ready for VS 2017
  4. Campus Labs
    Campus Labs avatar
    13 posts
    Member since:
    Jan 2007

    Posted 29 Oct 2010 Link to this post

    Thanks for your response, Iana. It looks like the solution you've provided will work when manually populating the RadFilter with a set of expressions. However, I'm trying to accomplish a slightly different task. I'll try to walk through my goal here.

    Let's say I have a RadFilter that can edit two fields – Number and Responsible Role. By default, the page loads with an empty RadFilter (that is, it has no expressions pre-populated). I click on the Add Expression button to get my first filter expression editor. By default, this editor will load "Number equal to _____" since Number is the first filterable field. At this point, let's say I want to filter by Responsible Role. I use the field name dropdown to change "Number" to "Responsible Role". Now the expression editor reads "Responsible Role equal to _____". It is here that "equal to" shows up as the default filter function and I’d like to change that default filter function to "contains".

    I apologize for not being clearer in my original post and appreciate your help.
  5. Answer
    Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 05 Nov 2010 Link to this post

    Hi Ross,

    There is a way to achieve your goal. You need to handle the ItemCommand and change the expression type there as in the attached sample.
    We will consider exposing new properties and events so this scenario is easily implemented.

    Check it out and let me know if this works for you.

    All the best,
    Iana
    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
  6. Leo
    Leo avatar
    20 posts
    Member since:
    Jul 2010

    Posted 11 Nov 2010 Link to this post

    Hi Iana,

    what if I want to replicate this behaviour when I click Add expression Button?
    Because I want that all fields get "Contains" as default filter expression...

    Thanks :)

    Leo
  7. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 11 Nov 2010 Link to this post

    Hello Leo,

    I assume that changing the if statement so it covers your requirement should be enough. Otherwise the logic used should be the same.

    Regards,
    Iana
    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
  8. Campus Labs
    Campus Labs avatar
    13 posts
    Member since:
    Jan 2007

    Posted 15 Nov 2010 Link to this post

    Thanks, Iana. That solution worked great.

    The only remaining issue was the expression being changed would be added to the end of the list of expressions in that group instead of remaining in the same location in the UI. I made a small change so the expression being edited remains in the same location:

    Int32 expressionIndex = e.ExpressionItem.OwnerGroup.Expression.Expressions.IndexOf(((RadFilterSingleExpressionItem)e.ExpressionItem).Expression);
                    e.ExpressionItem.OwnerGroup.Expression.Expressions.Remove(((RadFilterSingleExpressionItem)e.ExpressionItem).Expression);
                    e.ExpressionItem.OwnerGroup.Expression.Expressions.Insert(expressionIndex, newExpression);
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017