0

I have a list where the font style and color for the rows are conditionally formatted based on the value of the status column. I don't want to highlight the row, just change the font. Below is an example:

enter image description here

To achieve the font styles the below code works fine when "group by" is set to "expanded" but when I set the group by setting to "collapsed" the code not longer works. Evidently missing something but not sure what.

$(function(){
   $("td.ms-vb2").each(function(){
       var that = $(this);
       if (that.text() == "Not Approved"){
           that.parent("tr").children("td").css("color", "#B0E0E6");
           that.parent("tr").children("td").css("font-style", "italic");
            }
       else if (that.text() == "Pending"){
           that.parent("tr").children("td").css("color", "#FF0000");
           that.parent("tr").children("td").css("font-style", "italic");
            }
        });

1 Answer 1

0

Use JSLink to change the style of non approved items

See the question here: Color code item row based on column value in SharePoint Foundation 2013

6
  • For a wacky non-jQuery-Calculated-Column solution, see viewmaster365.com/#/How , works because it sets the TR style on every display, where as the jQuery solution only executes on page load Commented Dec 4, 2016 at 9:37
  • Tried the viewmaster365 solution but got some strange effects when hovering over the formatted rows, also I could only get background highlight but I wanted to only format font, thus reverted to the original code I posted. Now guessing that I could set to expanded as default then have js collapse the groupings.
    – skinnane
    Commented Dec 4, 2016 at 11:07
  • Then CSR with JSLinks is the SP route to take, start by disabling MDS, that will save you some dev headaches. But don't invest too much energy in it, it is unclear if and how, Microsoft will support CSR in Modern Experiences (and at the moment you can't add ANY code to those Modern Experiences) Commented Dec 4, 2016 at 13:39
  • See codeproject.com/Articles/620110/… Commented Dec 4, 2016 at 13:40
  • link Commented Dec 6, 2016 at 17:00

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.