Telerik Mvc Grid Extension Method to highlight grid row

Telerik Mvc Grid Extension Method to highlight InActive record

I was recently working on a project where in there was a requirement that all those grid rows which are inactive in database should be highlighted with a different colour. In this project we were working with Telerik Mvc extensions.

I googled for this, and most of the responses were like, to add a client side RowDataBound event to each of the grid & place the logic there.

According to me this is a bit of time consuming tasks. So after some research & a bit help from telerik MVC forums, I created my own extension method to highlight the grid row for which the column value of the IsActive column is false.

In our database, each of the table contains a column “IsActive” which stores a Boolean value “true” or “false” so as to represent the particular record is Active or not. A record with false value in “IsActive” column indicates that the record is InActive.

Here are some simple steps to achieve this.

  1. First we need to write an extension method which will add a handler to highlight the record. Here is the code snippet for that

2. Add following class to CSS

3. Add following javascript function to your master page

4. Append your grid like this

And that’s all we need to do the row will be highlighted like this

You can find the source code here