0

I'm new to SharePoint and trying to create a view on a list where it will only display the records, with odd ID numbers.

I created the following .css script and added it using Content Editor: style type = "text/css"> .ms-alternating {background-color: #FF0000;}

However the issue I'm running into, is that if there is a list of 10 items, if item number 6 gets pulled into another list (original list is used as staging area), then what was once colored, will no longer be colored. I am looking for a solution that would be dependent on the ID, so that the color will be static on each file. Thank you for your help.

1 Answer 1

1

You need to use JavaScript with Client Side Rendering to render rows based on ID in the list view.

Check if the ID is Even or Odd number by dividing the ID number by 2 (ID % 2). % will give the remainder value. If the remainder is 0 (zero) then it is an Even number, otherwise it is an Odd number.

If ID is Even number (or Odd number, per your requirement), set this row color (tr.style.backgroundColor = "#FF0000";)

Demos about how to color rows in list view based on the conditions with Client Side Rendering:

Rendering list view using Client Side Rendering

SharePoint 2013 Conditional formatting in list views

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.