英文:
How can I prevent a value from being rendered in the group header when using renderCell on a column in Material UI’s DataGrid?
问题
codesandbox 复制此问题: https://codesandbox.io/s/stupefied-gagarin-jgcnfl?file=/demo.tsx:563-672
渲染这个虚构示例的相关代码部分是 'asdf' 的 Id 行:
{
field: "id",
headerName: "ID",
width: 100,
renderCell: (params) => <div>"asdf"</div>
}
正如您所看到的,“asdf” 在可展开的组标题上呈现。我如何隐藏它,仅在展开组后显示它。注意:我需要返回 JSX,所以无法使用 valueFormatter
。
英文:
codesandbox replicating this issue: https://codesandbox.io/s/stupefied-gagarin-jgcnfl?file=/demo.tsx:563-672
relevant piece of code that renders this contrived example of 'asdf' for the Id row.:
{
field: "id",
headerName: "ID",
width: 100,
renderCell: (params) => <div>"asdf"</div>
}
And as you can see "asdf" render at on the expandable group header. How can I hide this and only show it for the rows once you expand the group. Note: I need it to return JSX, so I cannot use valueFormatter
答案1
得分: 1
renderCell: ({ rowNode }) => (
rowNode.type === "group" ? null : <div>asdf</div>
)
英文:
renderCell: ({ rowNode }) => (
rowNode.type === "group" ? null : <div>asdf</div>
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论