FilterMenuShowing not working properly

4 posts, 0 answers
  1. Sreenivas
    Sreenivas avatar
    12 posts
    Member since:
    Dec 2007

    Posted 17 Mar 2009 Link to this post

    Hi,
    I am working on Telerik version 2008.3.1314.35. Having problem with customizing filter menu items.
    I want the same functionality which is posted here http://www.telerik.com/help/aspnet-ajax/grdreducingfiltermenuoptions.html

    String type columns should only have StartsWith and Contains. But it works only first click. If I click on Integer column and all the items shows fine. But once I come back to string column I am able to see all the columns, some times I can see few of them. Its not consistent.

    Sample also attached. Please help me in this situation.

    Thanks
    Sreenivas.
  2. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 20 Mar 2009 Link to this post

    Hello Sreenivas,

    I am pasting here the response you received in the support ticket you opened with regards to this subject:

    "To achieve your goal you need to set a CSS class which will show and hide each Filter item.
    Here is a code snippet showing how to accomplish this task:
        <style type="text/css"
            .hideFilterOption 
            { 
                display: none !important;  
            } 
        </style> 
     
        <script type="text/javascript" language="javascript"
            var oldFilterStyle = ""
             
            function filterMenuShowing(sender, eventArgs) { 
                var menu = eventArgs.get_menu(); 
                var items = menu.get_items(); 
     
                if (eventArgs.get_column().get_dataType() == "System.String") { 
                    var i = 0; 
                    while (i < items.get_count()) { 
                        if (items.getItem(i).get_value() != "StartsWith" && items.getItem(i).get_value() != "Contains") { 
                            var item = items.getItem(i); 
                            if (item != null)  
                            { 
                                if (item.get_element().className != "hideFilterOption")  
                                { 
                                    oldFilterStyle = item.get_element().className
                                } 
                                item.get_element().className = "hideFilterOption"
                            } 
                        } 
                        i++; 
                    } 
                } 
                else { 
                    var i = 0; 
                    while (i < items.get_count()) { 
                        var item = items.getItem(i); 
                        if (item != null
                            if(oldFilterStyle != "" && item.get_element().className == "hideFilterOption"
                                item.get_element().className = oldFilterStyle; 
                        i++; 
                    } 
                } 
            } 
        </script> 

    Kind regards,
    Sebastian
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Sreenivas
    Sreenivas avatar
    12 posts
    Member since:
    Dec 2007

    Posted 30 Mar 2009 Link to this post

    This works great. Many thanks for your help.
  4. DogBizPro
    DogBizPro avatar
    158 posts
    Member since:
    Aug 2013

    Posted 11 Sep 2017 in reply to Sebastian Link to this post

    I cannot get this to work. It it not hiding any of the options.....
Back to Top