Recently, I had to implement a lot of Client Side Rendering in one of my projects. One of the requirements was to dynamically compare the two column values at the run time and assign the third column a value based on it. In addition to it, based on the new value assigned, the row had to be highlighted with different colors. Conditionally, assigning the value was fairly simple as mentioned here:

However, I had to color the code and the rows based on the value as well. Combining both the functionality was a challenge. Thanks to Andrey for helping me out here. We will see in detail, how we can implement it in this article.

products

Client side Rendering is a powerful option to modify the list views and list forms. It simply means that the data is transformed and displayed, using Client side technologies like HTML and JavaScript. Prior to SharePoint 2013, in case of any requirements to modify the list views, we had to use SharePoint Designer and XSLT formatting.

Essentially, JSLink taps into the list view rendering and overrides properties that govern the list view look and feel. Some of the properties that can be overridden are:

In this article, we will be overriding OnPostRender and Fields properties. "OnPostrender" allows us to modify the list view, once the view has been rendered. ‘Fields’ property helps us to override the styling behavior during rendering time. Similarly, each of the properties can be overridden during run time to accomplish different list view modifications and at different list view place holders.

Let’s see how we can modify the List view using JSLink and highlight the rows conditionally.

JSLink Implementation

Output

Output
Thus, we have conditionally assigned a value to Sales Progress column. Based on the value, we have highlighted the rows.