mvccontrib-grid

MvcContrib grid conditional cell formatting based on model value


I need to conditional formatting a cell value based on a boolean value in the model. I have the column col.For(item => item.Detail); If item.Unfinished I need to apply some css style How can I do that?


Solution

  • The answer is in my comment to the original post:

    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>();
    });