Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format boolean column in MVCContrib grid

I am using the MVCContrib grid and I would like to display images depending on the values of a column, e.g.:

  • if the column's value is null display the image "<img src="true.gif">"
  • otherwise display the image "<img src="false.gif">

Furthermore I would also need (this should be the same approeach I think) to display different actions depending on the column's/rows' value ...

Thanks in advance for your answers!

Best regards
Stefan

like image 468
Stefan Walther Avatar asked Feb 27 '23 20:02

Stefan Walther


1 Answers

The answer was quite 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(); %>
like image 133
Stefan Walther Avatar answered Mar 12 '23 06:03

Stefan Walther