【问题标题】:How to divide a table into two parts with headings Ag Grid Angular如何将带有标题 Ag Grid Angular 的表格分成两部分
【发布时间】:2020-05-13 10:34:59
【问题描述】:

我正在使用 ag-grid 开展一个项目,我想制作一个用户表,在同一个表中显示所有角色和部门的访问权限,如下所示:

| Permisssions |    transactions    |   inventory   |   orders
|--------------|------------------------------------------------  
| Departments  |
|--------------|------------------------------------------------
| depart1      |      xxx                 xxx           xxx
| depart2      |      xxx                 xxx           xxx
| depart3      |      xxx                 xxx           xxx
|              |
|----------------------------------------------------------------
| Roles
|----------------------------------------------------------------
| roles1       |      xxx                 xxx           xxx
| roles2       |      xxx                 xxx           xxx
| roles3       |      xxx                 xxx           xxx
|              |

我在与此相关的文档中找不到任何内容。如上例所示,表格分为两部分。

  • 部门
  • 角色

每个都有自己的副标题,列名和行也是动态的。请让我知道如何实现这一目标。提前致谢!

【问题讨论】:

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


    【解决方案1】:

    我能想到的最接近的是使用Aligned Grids

    您基本上定义了 2 个 ag-grids,但您可以同步对任一网格执行的操作。

    gridOptionsFirst = {
        // some grid options here
            ...
    };
    
    gridOptionsSecond = {
        // register first grid to receive events from the second
        alignedGrids: [gridOptionsFirst]
    
        // other grid options here
        ...
    }
    

    来自文档中的示例,

    1. 您可以为底部网格定义 0 的 headerHeight
    2. 在 2 个网格之间添加 <span> Roles </span>
    3. 将 cellStyle 赋予 Transaction、inventory、orders 列以移除边框

    并产生类似的东西

    | Departments  |  
    | Permisssions | transactions    |   inventory   |   orders  
    |--------------------------------------------------------------    
    | depart1      |      xxx                 xxx           xxx  
    | depart2      |      xxx                 xxx           xxx  
    | depart3      |      xxx                 xxx           xxx  
    |----------------------------------------------------------------  
    | Roles  
    |----------------------------------------------------------------  
    | roles1       |      xxx                 xxx           xxx  
    | roles2       |      xxx                 xxx           xxx  
    | roles3       |      xxx                 xxx           xxx  
    

    【讨论】:

    • 关闭但不是我真正想要的。我希望权限位于顶部,部门作为子标题也具有类似的角色
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-19
    • 2020-04-05
    • 1970-01-01
    • 2021-11-03
    • 2019-08-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多