Format logical column in MVCContrib grid

I am using the MVCContrib grid and I would like to display images depending on the values โ€‹โ€‹of the column, for example:

  • If the column value is null, display the image "<img src="true.gif">"
  • otherwise display the image "<img src="false.gif">

In addition, I will also need (it should be the same as I think) to display different actions depending on the value of the column / rows ...

Thanks in advance for your answers!

Regards, Stefan

+4
source share
1 answer

The answer was pretty simple :)

 <% Html.Grid(Model.Languages).Columns(column => { column.For(c => c.LanguageName).Named("Language"); column.For(c => c.LangCode).Named("Language Code"); column.For(c => c.IsDefaultLanguage ? "<img src=\"library/images/true.gif\">" : "<img src=\"library/images/false.gif\">").Named("Default Language").DoNotEncode(); } ).Empty("There is no language available") .Render(); %> 
+8
source

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


All Articles