SlickGrid 2.0无法更改奇数索引中的行背景颜色 [英] SlickGrid 2.0 can't change row background color in odd indexes

查看:109
本文介绍了SlickGrid 2.0无法更改奇数索引中的行背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码更改背景颜色:

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)

谢谢。

推荐答案

您的未验证的 CSS类已应用,但无效,因为它的特异性低于 slick-default-theme.css中定义的特性

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.

您有两个选择:


  1. 删除现有规则。

  2. 通过添加 .slick-row <来提高规则的特异性/ code>并将其放在文档中的现有规则之后,或者添加!在样式声明结束时重要的

  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.

这篇关于SlickGrid 2.0无法更改奇数索引中的行背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆