asp.net-mvcformatbooleanmvccontrib-grid

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.:

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


Solution

  • 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(); %>