AG-Grid动态列标题文本 [英] AG-Grid dynamic column header text
本文介绍了AG-Grid动态列标题文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这似乎很简单,但事实证明并非如此。由于某些原因, headerName
会转换为字符串,因此它不能成为函数。
This seems like it'd be simple but it's proving otherwise. For some reason headerName
is converted to a string and so it can't be a function.
我已经还尝试了各种 renderer
和 headerComponent
函数,但是就像我说的,我只想返回一个动态字符串,而不是覆盖所有内容并且必须重新实现它(例如,使用自定义标头组件的情况)。
I've also tried various renderer
and headerComponent
functions but like I said, I just want to return a dynamic string, not override everything and have to re-implement it (such as with the case of a custom header component).
// I'm trying everything at this point, nothing renders out..
getHeaderCellTemplate: () => 'test 2',
headerCellTemplate: () => {
// What I actually want to achieve:
const currency = appModel.selectedCertificate().currency();
return currency ? `Total Value (${currency})` : 'Total Value';
},
headerCellRenderer: HeaderCellRenderer,
headerComponent: HeaderCellRenderer,
cellRenderer: () => 'test 7',
headerRenderer: () => 'test 9',
我知道我可以将列def包装在函数中,但这是
I know I could wrap the column def in a function, but this would be very inefficient as the column def would be re-created every render.
推荐答案
我希望这样对您有用:
headerValueGetter: (params) => {
const currency = appModel.selectedCertificate().currency();
return currency ? `Total Value (${currency})` : 'Total Value';
}
这篇关于AG-Grid动态列标题文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文