This is a migrated thread and some comments may be shown as answers.

FilterMenuShowing not working properly

3 Answers 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sreenivas
Top achievements
Rank 1
Sreenivas asked on 17 Mar 2009, 08:09 PM
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.

3 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 20 Mar 2009, 04:38 PM
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.
0
Sreenivas
Top achievements
Rank 1
answered on 30 Mar 2009, 05:47 PM
This works great. Many thanks for your help.
0
DogBizPro
Top achievements
Rank 1
answered on 11 Sep 2017, 02:09 PM
I cannot get this to work. It it not hiding any of the options.....
Tags
Grid
Asked by
Sreenivas
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Sreenivas
Top achievements
Rank 1
DogBizPro
Top achievements
Rank 1
Share this question
or