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

[Solved] Boolean Filter Template

2 Answers 121 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.
Mac
Top achievements
Rank 1
Mac asked on 28 Nov 2011, 05:21 PM
Hi, Is there a way to change the Filter display to change True/False to Yes/No for Booleans?

I know the Column Template can be done with the following:

.ClientTemplate("<#= BooleanField? 'Yes' : 'No' #>")

However, if you do that and enable filtering, then the language is out of sync on the Grid.

This question was asked a year and a half ago, but no answer:

http://www.telerik.com/community/forums/aspnet-mvc/grid/filter-template-for-boolean-values.aspx

Thanks,
Calvin

2 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 29 Nov 2011, 03:05 PM
Hi Calvin,

One way to achieve this is to use custom localization and change the display message for FilterBoolIsFalse and FilterBoolIsTrue. 

Another way to do this is to bind a javascript function to the click event of the filter icon and change the values of the labels manually.
e.g.

...
.ClientEvents(e => e.OnLoad("onLoad"))
)
 
 
 
<script type="text/javascript">
    function onLoad() {
        $(this).find("th .t-grid-filter").click(function () {
            setTimeout(function () {
                $('div.t-filter-options label[for="GridPersonsMalefalse"]').html('is female');
                $('div.t-filter-options label[for="GridPersonsMaletrue"]').html('is male');
            }, 10);
        });
    }      
</script>



All the best,
Petur Subev
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
0
Alex
Top achievements
Rank 1
answered on 08 Feb 2012, 09:13 PM
Thanks for the info, Petur.  It would be great if we could configure the filter settings fluently.
Tags
Grid
Asked by
Mac
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Alex
Top achievements
Rank 1
Share this question
or