我想在每一列中与它的数据相对应的每个项目前面添加一个图标。当前,我仅使用JS数组显示静态数据,但无法自定义它。
现在使用此:
<MaterialTable
title="Title"
columns={this.state.columns}
data={newDataTable}
options={{
selection: true
}}
options={{
search: false,
sorting: true
}}
actions={[
{
icon: () => <Checkbox />,
tooltip: 'checkbox'
},
{
icon: () => <InfoIcon />,
tooltip: 'info',
onClick: (event, item) => {
this.setState({
isOpen: true,
selectedItem: item
});
}
}
]}
/>
答案 0 :(得分:0)
我假设您使用的是:https://github.com/mbrn/material-table。
在将数据传递到表之前,可以添加如下图标:
const newData = newDataTable.map((value) => ({...value, firstColumn: <SomeIcon />}));
并添加带有{ title: "", field: "firstColumn" }"
的列。