Over recent weeks I have been using the excellent Telrik UI for MVC. It appears a little pricey but offers excellent controls and saved weeks of development time. The grid is particularly excellent and tremendously flexible. the documentation is very complete but it isn’t always entirely obvious how to achieve certain things: one of those is grid conditional cell formatting.
As with most things there are a number of ways to achieve this but I’m going to get straight in there with a really simple solution. In order to keep this short I’m going to skip a lot of the setup on the basis that if you know you need to achieve this then you will already know the basics of using the grid and ASP.NET MVC.
Here’s our starting grid with a basic product model that has an enum for availability.
As you will know, an enum a set of named constants with a default type of Integer.