Tag Archive for Customize list column

Sharepoint: Apply background color to custom list column based on other column value

Today we are going to learn how to apply the background color to a custom list column based on other column value, firstly, I tried this scenario using calculated formula column type but some javascript code is needed to render the background color based on calculated formula value,  so I did some research and come up with the best easy way…..

STEPS:

I have created a simple custom list and name it as ‘My List

Modified the ‘Title‘ column name as ‘Student Name

Created one more column ‘Subject‘ which is of type single line text

Also, created one column ‘Marks‘ which is of type Number min is 1 and max is 100

Open the AllItems.aspx page using Sharepoint Designer 2007

Select the list, right click and Convert into XSLT mode

Write the XSL condition in between the ‘Subject TD tag as show in the below image

Here goes the XSL code……



background-color:Green;


background-color:Yellow;


background-color:Red;

XSL condition in Sharepoint Designer 2007

XSL condition in Sharepoint Designer 2007

Output:

Background color to Sharepoint Custom List column based on Marks

Background color to Sharepoint Custom List column based on Marks

Change the Color of a Column in a List in SharePoint

In this article, we will know how to change the color of a column based upon the values in the column. It is something like “Color Indicator” in SharePoint.
 
Scenario:
We have a custom list used for Project Tracking. In the list, we have column named STATUSfor tracking the project.
Whenever an item in the list is updated with the status in the column, then the background color of the status column should automatically change depending upon the status. Hence it gives a proper UI for tracking the status.
 
Solution:
1. Create a custom list named “Project Tracking System” with the columns such as “Title”, “Description” and Status with the data type as shown below:
 

Columns with the data types to be created:

 
2. Now, we will insert 4-5 items in the list created.
In the above list, we can see that the status column is updated, but it would be good when we have background color of the each status separately. It is gives easy tracking to the users.
3. We can achieve this through JAVA SCRIPT.
4. Add a Content Editor Web part below the list as shown below:

5. Now in the content editor web part, add the below java script code (Open the tool pane -> Source Editor -> Place the Java Script -> Click Ok) and save the page.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
6. Now, you can see the status column background is changed depending upon the status inserted for each item as shown below:
It is gives good interface to the users and also we can categorize the status easily.