reactjs - 动态添加 colDefs
问题描述
我正在尝试在单击按钮时以编程方式添加列定义,而不是在我的 ReactJS 页面中对其进行硬编码。
{
headerName: "Product1",
resizable: true,
wrapText: true,
cellStyle: {
'white-space': 'normal'
},
autoHeight: true,
hide: true,
cellRendererFramework.MyCustomColumnRenderer
}
不确定如何实施?谢谢你的帮助。
解决方案
利用setColumnDefs(columnDefs)
const columnDefs = getColumnDefs();
columnDefs.forEach(function (colDef, index) {
colDef.headerName = 'Abcd';
});
this.gridApi.setColumnDefs(columnDefs);
推荐阅读
- python - 在日期最接近的一个键和值位于任意两列的另一个键上合并两个表
- google-cloud-platform - Google Cloud 数据流和 Cloud Functions 错误 - ModuleNotFoundError
- python - 使用 python 正则表达式重复模式
- visual-studio-code - 如何在 VSCode 中禁用 ^M 行尾?
- mysql - 为什么 MySQL SUM IF 在 2021 年退出工作
- ios - 在哪里可以查看大型 iOS 代码库以了解其组织方式?
- javascript - 如何在我的方法中通过 Paypal Orders API 的使用授权以及我应该返回什么?
- ios - 无法在 iOS 中初始化 crashlytics
- python - 变量中的 Python 字符串方法
- python - python,如何获得更平滑的值?