【问题标题】:Is it possible to put borders around row groups in ag-grid是否可以在 ag-grid 中的行组周围放置边框
【发布时间】:2021-01-03 10:06:53
【问题描述】:

有没有人在行组周围设置边框以帮助他们的网格更易于阅读?如果是这样,任何指导将不胜感激。

【问题讨论】:

    标签: ag-grid ag-grid-angular ag-grid-react


    【解决方案1】:

    您可以使用getRowStyle 指定需要设置样式的行。在您的情况下,您可以通过检查 RowNode.group 是否为 true 来确定某行是普通行还是行组。

    AgGrid 仅使用border-top 来设置行边框样式。一行的border-bottom 实际上是它下面一行的border-top,这意味着您可以通过设置组中第一个子项的border-top (RowNode.firstChild) 的样式来直观地设置行组的border-bottom

    这是一个例子:

    const getRowStyle = (params) => {
      const { node } = params;
      if (
        (node.rowIndex !== 0 && node.group) ||
        (!node.group && node.firstChild)
      ) {
        return { borderTop: "pink solid 1px !important" };
      }
    }
    

    现场演示

    【讨论】:

    • 这太棒了!我能够获得我需要的功能。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2011-04-05
    • 1970-01-01
    • 2021-09-21
    • 1970-01-01
    • 2020-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多