【问题标题】:Problem with cell style in pivot mode Ag-grid枢轴模式Ag-grid中的单元格样式问题
【发布时间】:2020-08-31 00:23:00
【问题描述】:

我在枢轴模式下的单元格样式存在问题:行组和简单网格等所有模式都可以正常工作,但是当我更改为枢轴模式时,只有行样式有效,而单元格样式不起作用。

请看下面的链接

https://plnkr.co/edit/8AFyzB5XvqlQg51Q

我在 colDef 中使用此代码

 cellStyle: {color: 'red', 'background-color': 'green'}

和gridOptions中的getRowStyle

var gridOptions = {
    getRowStyle : function(params) {
        if (params.node.rowIndex % 2 === 0) {
            return { background: 'blue' };
        }
   }
}

请指导我。

【问题讨论】:

    标签: pivot ag-grid


    【解决方案1】:

    AG-grid 中的coldef 指的是一个简单的列,但是当您执行分组和旋转它不再是一个简单的列时,它就变成了一个 groupcolumn,如果它的 autogroupcolumn 然后 ag grid 生成它。因此,如果您想在分组或透视模式下将样式应用于行组,那么您必须像这样定义它。

        autoGroupColumnDef: {
        width: 180,
        cellStyle: function(params) {
            //check that the autogroup is built using country column and then color every odd cell 
            if(params.node.field ==='country' && params.node.rowIndex% 2 === 1){
            return {color: 'red', 'background-color': 'white'}
                   }
                 }
              },
    

    查看fiddle 以查看工作演示

    【讨论】:

      猜你喜欢
      • 2021-08-31
      • 2018-07-17
      • 2019-03-10
      • 1970-01-01
      • 2018-01-25
      • 2019-12-26
      • 2023-03-18
      • 1970-01-01
      • 2021-07-16
      相关资源
      最近更新 更多