SharePoint

Highlight a list/library line item

I blogged on this a while back using a similar approach for MOSS 2007.  Here is a link to that post: https://www.saltypc.com/?p=99

Things have changed since then so here are the steps to set this up in 2013.

You will need to reference jquery for this to work.  I prefer to download the minified script and place it in a centralized location inside my farm.

  1. Add a script editor web part to the bottom of your page.
  2. Insert the following into your source:
  • <script type="text/javascript" src="http://yoursitename.com/js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
     $(document).ready(function(){
      $Text = $("td.ms-cellstyle.ms-vb2:contains('Change Me')"); $Text.parent().css("background-color", "#99FF66");
     });
    </script>

Modify the Change Me to reflect the column name of your list/library.  You can also change the color to any web safe color of your choice.

To highlight mulitple column choices, simply copy the $Text line and past it below the copied line.

Example:

$Text = $(“td.ms-cellstyle.ms-vb2:contains(‘Column A)”); $Text.parent().css(“background-color”, “#FFFFFF”);

$Text = $(“td.ms-cellstyle.ms-vb2:contains(‘Column B)”); $Text.parent().css(“background-color”, “#000000”);

This comes in handy when you need to find a needle in a haystack.

 

Stay Salty!

2 thoughts on “Highlight a list/library line item

  1. Hello, I noticed that if you sort any of the columns in the list or library, the color highlighting disappears. Is it just me or does this happen for you too?

  2. If you are sorting on the fly, this will happen. This will also happen if you have groups setup in your view. Basically, this prevents the javascript from firing and in a sense, ‘breaks’ the highlighter control.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.