Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SlickGrid 2.0 can't change row background color in odd indexes

I'm trying to change the background color using this code:

  data.getItemMetadata = function (index)
  {
       if (index === 5)
       {
           return  {cssClasses: "Unverified"};
       }      
   }

It works perfect as long as the index is even. but with odd indexes it has no effect on the background color (it has effect on the font style). I suspect it has something to do with the zebra effect? (I don't know how to disable that)

Thanks.

like image 525
Slime recipe Avatar asked Nov 12 '12 13:11

Slime recipe


1 Answers

Your Unverified CSS class gets applied, but has no effect because it's specificity is lower than what is defined in slick-default-theme.css:

.slick-row.odd {
  background: #fafafa;
}

Notice that the selector uses a combination of two classes, which is more specific than your single Unverified class, hence it takes precedence.

You have two options:

  1. Remove the existing rule.
  2. Increase the specificity of your rule by adding .slick-row and placing it after the existing rule in the document, or by adding ! important at the end of your style declaration.
like image 153
Tin Avatar answered Nov 08 '22 18:11

Tin