最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to make Column group expandcollapse work in AgGrid? - Stack Overflow

programmeradmin0浏览0评论

I have an AgGrid configured with the following column definitions:

const colDefs = ref([
  {
    field: "make"
  },
  { field: "model" },
  {
    headerName: "Col Group",
    columnGroupShow: "open",
    children: [{ field: "price" }, { field: "electric" }],
  },
]);

As you can see, I have configured a column group named "Col Group" and according to AgGrid documentation, there should be an option to collapse and expand the group, but I don't see it in my grid.

Here's a working example

Am I missing something or doing something wrong? How can I have the collapse/expand options working for this column group?

I have an AgGrid configured with the following column definitions:

const colDefs = ref([
  {
    field: "make"
  },
  { field: "model" },
  {
    headerName: "Col Group",
    columnGroupShow: "open",
    children: [{ field: "price" }, { field: "electric" }],
  },
]);

As you can see, I have configured a column group named "Col Group" and according to AgGrid documentation, there should be an option to collapse and expand the group, but I don't see it in my grid.

Here's a working example

Am I missing something or doing something wrong? How can I have the collapse/expand options working for this column group?

Share Improve this question asked Nov 20, 2024 at 10:38 gespinhagespinha 8,49717 gold badges59 silver badges95 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You need to set the columnGroupShow field on the children, not on the column def itself. Here is your updated code:

const colDefs = ref([
  {
    field: "make",
  },
  { field: "model" },
  {
    headerName: "Col Group",
    children: [{ columnGroupShow: "open", field: "price" }, { columnGroupShow: "closed", field: "electric" }],
  },
]);
发布评论

评论列表(0)

  1. 暂无评论