在 viewConfig 属性的 getRowClass 中分配颜色代码后,背景颜色不会更改

Background color does not change after assigning color code in getRowClass at viewConfig property

本文关键字:颜色 背景 代码 属性 getRowClass 分配 viewConfig      更新时间:2023-09-26

在这里,是JavaScript,我在其中设置了在业务对象列和自定义表列中包含不同数据的字段的背景颜色。

projectgrid= new Ext.grid.GridPanel
     ({
         id:projectgrid,
         cm : projectInfoFieldsCM,
         store: inlineGridStore,
         stripeRows: true,
         autoScroll:true,
         width:550,
         height:500,
         bodyCssClass : 'customInlineGridCSS',
         viewConfig: 
         {
            forceFit: false,
            autoFill : false,
            deferEmptyText : false,
            emptyText : '<div align="center"><span style="font-size: 9pt; font-weight: normal">No record available</span></span></div>',
            getRowClass: function(record, index, rowParams, store) {
                if(record.get('BusinessObject')!=record.get('CustomTable')){
                     return 'gender-male';
                }
            }
         }
      });

在这里,是我在其中分配颜色编码的css文件。注意:我尝试了在css文件中声明的两个ID。

             .data-row-light-red
            {
            background-color: #ff0000 !important ;
            }
            .gender-male .ID {
                background-color: #088da5;
            }

我做错了什么,因为我以前已经实现了此功能,但我被困在这个功能中?

也许不希望你完全需要,但我已经在列中对渲染器函数做了类似的事情,也许你也可以使用它?

这是我的代码:

 columns: [
   {header: "Color", dataIndex: "COLOR", width:100,
     renderer: 
       function(value, metaData, record, rowIndex, colIndex, store){
         metaData.style = "background-color: rgb(255,255,255);";
         return "";
       }                                        
  },

希望这有帮助

您需要使用逗号分隔类选择器

试试这个

.gender-male, .ID
{
   background-color: #088da5;
}

.gender-male
{
   background-color: #088da5;
}

如果您在任何地方都不需要 ID 类