reactjs - react grid - 调用渲染单元格的函数
问题描述
我react-data-table-component
在反应中用作网格组件。我已经设置了一个列数组,例如:
this.columns = [
{
name: 'Id',
selector: 'FileId',
sortable: true,
left: true,
width: "80px",
cell: function (row) {
return <div title={row.FileName}>{row.FileName}</div>;
}
},
{
name: 'Info',
selector: 'FileId',
sortable: false,
left: true,
width: "80px"
},
现在,当我想在 o 中添加这样的自定义渲染器时
{
name: 'File Name',
selector: 'FileName',
sortable: true,
left: true,
width: "250px",
cell: function (row) {
this.calculateWarnings(row);
}
},
我收到与范围有关的错误。
我确实添加到构造函数:
this.calculateWarnings = this.calculateWarnings.bind(this);
我错过了什么
解决方案
替换这个
cell: function (row) {
有了这个
cell: (row) => {