【问题标题】:In ag-Grid when I change the row background, there is no color for selected row (blue by default)在 ag-Grid 中,当我更改行背景时,所选行没有颜色(默认为蓝色)
【发布时间】:2020-04-05 19:27:44
【问题描述】:

在 ag-Grid 中,当我更改行背景颜色时,它工作正常,但是当我选择行时,颜色不会变为蓝色,因此我可以识别该行已被选中。

我正在使用 gridOptions.getRowStyle 来更改行背景颜色:

gridOptions.getRowStyle = function(params) {
    return { background: "#3a3a3a" }
}

【问题讨论】:

    标签: ag-grid


    【解决方案1】:

    我的方法是使用 ag-grid 中的 rowClass 选项。

    rowClass: 'my-row'
    

    然后在你的css中你可以定义:

    .ag-root .my-row:not(.ag-row-selected) {
      background-color: #3a3a3a;
    }
    

    https://embed.plnkr.co/fTENsl/

    如果您想要自定义选择的颜色,另一种选择是使用这个:

    .ag-root .my-row {
      background-color: #3a3a3a;
    }
    
    .ag-root .my-row.ag-row-selected {
      background-color: blue;
    }
    

    【讨论】:

      【解决方案2】:

      如果你想在 css 中改变选中行的样式,使用 class

      .ag-row-selected {
        background-color: black;
        color: white ;
        border-color: gray;
      }
      

      【讨论】:

      • color 工作正常,但是当我使用 API 为行着色时,颜色在选择时不会改变,边框也不起作用。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-16
      • 1970-01-01
      • 1970-01-01
      • 2021-07-20
      • 2021-11-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多