You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Ag-Grid单个单元格内展示多个子单元格?

问题:在Ag-Grid单个单元格内展示多个子单元格

需求与现状

  • 需要在Ag-Grid的单个单元格中展示多个子单元格,期望效果类似Excel中多行子单元格嵌入的样式
  • 尝试过Ag-Grid的Row Spanning功能,但该方式仅实现单元格合并,且只能访问设置了rowspan的单元格,不符合需求
  • 目前的实现效果与期望效果存在差距

当前代码实现

function rowSpan(params: RowSpanParams) {
  return params.data.tasks.length > 0 ? params.data.tasks.length : 1;
}

public columnDefs: (ColDef | ColGroupDef)[] = [
    {
      headerName: 'Code',
      field: 'code',
      editable: true,
      onCellClicked(event) {
        window.location.href = `/shots/${event.data.id}`;
      },
      rowSpan: rowSpan,
      cellClass: "cell",
    },
    {
      headerName: 'Sequence',
      field: 'sequence.code',
      editable: true,
    },
    {
      headerName: 'ANIM',
      children: [
        {
          headerName: 'Status',
          field: 'tasks.status',
          columnGroupShow: 'closed',
        },
        {
          headerName: 'Task Name',
          field: 'tasks',
          columnGroupShow: 'closed',
        },
      ],
    },
  ];

后端返回的数据结构

[
 {
  "code": "sc01_0090",
  "description": null,
  "sequence": {
    "code": "sc01"
  },
  "tasks": [
    {
      "content": "layout",
      "status": "wtg"
    },
    {
      "content": "animation",
      "status": "ip"
    },
    {
      "content": "lighting",
      "status": "wtg"
    },
    {
      "content": "compose",
      "status": "wtg"
    }
  ]
 },
 ...
]

内容的提问来源于stack exchange,提问作者Vlad Fedotov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 13:00:09