开发者

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 sho开发者_运维问答uld 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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜