Customise Filter Expression Text

5 posts, 1 answers
  1. Fergal
    Fergal avatar
    23 posts
    Member since:
    Jun 2012

    Posted 13 Feb 2013 Link to this post

    Is it possible to edit the display text for the RadFilter Expressions? For instance, on the RadFilter, you see an Expression for "StartsWith" - is it possible to edit that text (to enter a space for example: "Starts With"), but not actually change the functionality of the expression object?

    I don't want to have to implement my own set of expressions, just alter the display text of the items already there.

    Thanks
    Fergal
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Feb 2013 Link to this post

    Hi,

    Try setting the following.
    aspx:
    <telerik:RadFilter ID="RadFilter" runat="server" Localization-FilterFunctionStartsWith="Starts with"></telerik:RadFilter>

    Thanks,
    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Fergal
    Fergal avatar
    23 posts
    Member since:
    Jun 2012

    Posted 13 Feb 2013 Link to this post

    Looks like exactly the feature I wanted, thanks!
  5. Fergal
    Fergal avatar
    23 posts
    Member since:
    Jun 2012

    Posted 14 Feb 2013 Link to this post

    Next Question: Can I change the text in the Expression Preview?

    For example, I've changed "IsNull" to display "IsPresent" - I'd like to write that out in the Expression Preview in a user readable format that matches the display text.
  6. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 18 Feb 2013 Link to this post

    Hello Fergal,

    In order to achieve this you can use this code snippet:
    function pageLoad(sender, args)
            {
                var filter = $find("<%=RadFilter1.ClientID %>");
                var menu = filter.get_contextMenu();
                menu.add_showing(FilterMenuShowing);
     
                var elements = document.getElementsByTagName("a");
                for (var i = 0; i < elements.length; i++)
                {
                    if (elements[i].className && elements[i].className.indexOf("rfExp") != -1 &&
                        elements[i].innerHTML == "IsNull")
                    {
                        elements[i].innerHTML = "IsPresent";
                    }
                }
            }
     
            function FilterMenuShowing(sender, args)
            {
               sender.findItemByValue("IsNull").set_text("IsPresent");
            }

    In the example provided the IsNull value is replaced both in the field editor and in the context menu.

    All the best,
    Angel Petrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017