【问题标题】:Ag Grid - React- Change the Grouped row colour Based on group data status -Ag Grid - React- 根据组数据状态更改分组行颜色 -
【发布时间】:2019-12-14 05:20:05
【问题描述】:

我想根据组数据状态更改组行的颜色。

Ag Grid sample Problem Image

Detailed problem image

根据上图,我想改变 2008 年的背景颜色,如果所有下面的行游泳。有人可以帮我解决这个问题。非常感谢您的帮助。

Ag Grid - 反应

【问题讨论】:

  • 欢迎您,@Ganesh Koilada!您可以将图像直接嵌入到您的问题中。如果可能,我建议您添加更多详细信息。

标签: ag-grid ag-grid-react


【解决方案1】:

您可以在 columnDefs 道具中定义“cellStyle”属性,并根据数据直接在那里处理颜色。

var columnDef = [{
  // Other columns
  ...
  {
    headerName: "Year",
    field: "year",
    cellStyle: function(params) {
      // adjust params.node.data.year depending on the of your attribute
      const year = params.node.data.year;
      
      // Default value
      let background = "#333";
      
      if (year === 2008) {
        background = "#f60"
      } 
      
      return background;
    }
  },
  // Other columns
  ...
];

如果您可以对自己的代码进行堆栈闪电战,我们会更容易为您提供帮助。

良好的编码。

【讨论】:

  • 感谢您的回答,但问题是需要突出显示分组行 2008 而不是行数据中的 2008。即当我单击按年分组时,需要按行分组。
  • @GaneshKoilada 你能用你的问题代码更新你的问题吗?
  • @@jbergeron 我尝试了 cellStyle 和 rowStyle 但它们不适用于分组行,我又附上了一张图片。你能检查一下吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-31
  • 1970-01-01
  • 2021-02-17
  • 1970-01-01
  • 2018-02-25
  • 2017-11-27
相关资源
最近更新 更多