MvcContrib基于模型值的网格条件单元格格式

Rod*_*rez 9 mvccontrib-grid

我需要根据模型中的布尔值条件格式化单元格值.我有列col.For(item => item.Detail); 如果item.Unfinished我需要应用一些CSS样式我该怎么做?

Rod*_*rez 9

答案在我对原帖的评论中:

http://groups.google.com/group/mvccontrib-discuss/browse_thread/thread/f872d298cc9d53dc

column.For(x => x.Surname).Attributes(x => {
    if(x.Item.Surname == "foo") {
        return new Dictionary<string, object> { { "style", "color:red"} };
    }
    return new Dictionary<string, object>();
});
Run Code Online (Sandbox Code Playgroud)