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

[Solved] How to remove the ‘Is not equal to’ and ‘Ends with’ filter menu options in telerik mvc grid?

1 Answer 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Narayanarao
Top achievements
Rank 1
Narayanarao asked on 08 Nov 2011, 01:57 PM
We have requirement to remove the ‘Is not equal to’ and ‘Ends with’ filter menu options of telerik grid. And we need to hide the total "And" section which contains dropdown filter options and text box. Is there anybody has the solution for this? Please do the needful.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 09 Nov 2011, 04:29 PM

Hello Narayanarao,

You can achieve the desired result by subscribing to the client side OnLoad event and removing the required filters, by using jQuery. The snippet below shows how to do that:

@( Html.Telerik().Grid<GridCustomFilterOptions.Models.Product>()
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(p => p.ID).Width(100);
            columns.Bound(p => p.Name);
        })          
        .Sortable()
        .Filterable()
        .DataBinding(dataBinding => dataBinding.Ajax().Select("Select", "Home"))
        .ClientEvents(events => events.OnLoad("onLoad"))            
    )
<script type="text/javascript">
    function onLoad() {
        $(this).find("th .t-grid-filter").click(function () {
            setTimeout(function () {
                $(".t-filter-options:visible option:contains(Ends with)").remove();
                $(".t-filter-options:visible option:contains(not equal)").remove();
                $(".t-filter-help-text:contains('And')").nextUntil(".t-button").andSelf().remove();
            }, 10);
        });
    }              
</script>
I also attached a sample project which contains the complete example.

All the best,
Daniel
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
Narayanarao
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or