如何在 SlickGrid 中的某些行上设置行背颜色

本文关键字:设置 颜色 SlickGrid | 更新日期: 2023-09-27 18:36:07

我想将 SlickGrid 中的前 3 行着色为蓝色。我想知道这样做的简单方法。

我尝试了以下代码,但它不起作用:

data.getItemMetadata = function (index)
{
   if (index == 0 || index == 1 || index == 2)
   {
       return  {cssClasses: "BlueColor"};
   }      
 }

如何在 SlickGrid 中的某些行上设置行背颜色

您可以使用

以下 CSS:

.slick-row:nth-child(-n+3){
    /*BlueColor class contents, if you place it before the .even and .odd classes you will need :important*/
}