Color of Selected Row

Color of Selected Row

ngungongungo Posts: 64Questions: 23Answers: 2

How do I change color of selected row?
I searched but could not find it :)
I also tried this but it doesn't work.
I need a hint. Thanks!

"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
  if ($(nRow).hasClass("selected")) $(nRow).css('color', 'white');      
  // if ($(nRow).hasClass("active")) $(nRow).css('color', 'white');     
},

This question has an accepted answers - jump to answer

Answers

  • DirceuNazarethDirceuNazareth Posts: 44Questions: 1Answers: 12

    The faster reliable way to do that is by CSS.

    tr.selected{
    color: #ffffff;
    }

    if you don't have access to CSS you can also do:

    $(document).ready(function(){
      var sheet = (function() {
        // Create the <style> tag
        var style = document.createElement("style");
    
        // Add a media (and/or media query) here if you'd like!
        // style.setAttribute("media", "screen")
        // style.setAttribute("media", "only screen and (max-width : 1024px)")
    
        // WebKit hack :(
        style.appendChild(document.createTextNode(""));
    
        // Add the <style> element to the page
        document.head.appendChild(style);
    
        return style.sheet;
      })();
      //insert a rule in your CSS
      sheet.insertRule("tr.selected{ color: #ffffff; }", 0);
    }
    
  • ngungongungo Posts: 64Questions: 23Answers: 2
    edited September 2016

    Hi DirceuNazareth,
    I am talking about selecting a row for editing.
    I have access to CSS and

    tr.selected {
      color: #ffffff;
    }
    

    does not work. Then I tried the script you gave. It does not work either.

  • ngungongungo Posts: 64Questions: 23Answers: 2
    edited September 2016

    Hi DirceuNazareth,
    I know why it does not work, in my case. I need to work it out then get back here to let you know. Sorry!

  • ngungongungo Posts: 64Questions: 23Answers: 2
    Answer ✓

    Everything is working now. :)

  • DirceuNazarethDirceuNazareth Posts: 44Questions: 1Answers: 12

    thank you for the feedback

This discussion has been closed.