How to convert a boolean value from true / false to yes / no in Telerik ASP.NET MVC Grid

I would like to be able to change the display value of a non-editable column on a non-editable Telerik AJAX grid in ASP.NET MVC. The column in question is the sot boolean on which the transformation will be displayed: Yes = true and No-False.

+6
source share
4 answers

I experimented a bit and found this to work. Not sure if it will be stored in an editable column, but in my case the column is not editable.

<% Html.Telerik().Grid<SomeClass>() .Name("SomeGrid") .Columns(columns => { columns.Bound(o => o.ReportingPeriodShortDescription); columns.Bound(o => o.Closed) .ClientTemplate("<#=Closed ? 'Yes' : 'No' #>") .Title("Closed") .Width("4em"); }) .Footer(false) .Render(); %> 
+6
source

Use a template to convert a value from True / False to Yes / No. Here is an example of how to do this:

http://www.telerik.com/community/forums/aspnet-ajax/grid/how-do-i-show-yes-no-for-boolean-columns-instead-of-true-false.aspx

0
source

I found an example on Telerik forums that do this based on bindings to a server or client.

http://www.telerik.com/community/forums/aspnet-mvc/grid/changing-a-bool-field-to-display-yes-no.aspx

In my case, I use AJAX binding, so I need ClientTemplate:

 columns.Bound(model => model.SubLimits).Title("Sublimits").Width(100) .ClientTemplate("<#=SubLimits?'Yes':'No'#>"); 
0
source

I struggled with this for a while. In my case, the <> around the expression in the ClientTemplate does not seem to work. I discovered a problem by looking at the generated html - it generated tags like <no></no>. The following functions are great for me:

  columns.Bound(c => c.DHSLane).Title("DHS Lane") .ClientTemplate("#=DHSLane?'Yes':'No'#") 
0
source

Source: https://habr.com/ru/post/887850/


All Articles