【发布时间】:2020-05-23 10:04:24
【问题描述】:
我正在尝试在 ag-grid(社区版)单元格上应用多个单元格类。我想更改单元格背景并将单元格字体设置为等宽。我定义了两个columnTypes:tomatoBackground 和monospaceFont。接下来,我设置表列“类型”属性,同时提供 columnTypes。
columnDefs: [
{
headerName: "Athlete",
field: "athlete"
},
{
headerName: "Sport",
field: "sport"
},
{
headerName: "Age",
field: "age",
type: ["tomatoBackground", "monospaceFont"]
}
]
columnTypes: {
tomatoBackground: {
cellClass: "ag-cell--tomato-background"
},
monospaceFont: {
cellClass: "ag-cell--monospace-font"
}
}
CSS 代码:
.ag-cell {
&--tomato-background {
background-color: tomato;
}
&--monospace-font {
font-family: monospace, 'Roboto', sans-serif;
}
}
不幸的是,只有最后一个 cellClass 实际应用于“年龄”列(在这种情况下是 monospaceFont)。 创建一个同时具有 CSS 属性(tomato background 和 等宽字体)的 CSS 类对我来说不是一个选项。
谁能帮忙解决这个问题?甚至可能吗?一个例子将不胜感激。
【问题讨论】:
标签: css ag-grid ag-grid-react