有没有办法在 onRowUpdate 中编辑 "edit " 图标?
is there a way to edit the "edit " icon in onRowUpdate?
我想在 material-table 中设置 属性 editable 时看到不同的图标和工具提示,但我找不到方法。我知道有可能覆盖一个组件,但没有任何效果。像这样的东西可能...
components={{
EditRow: props => (
<MTableEditRow
{...props}
icons={{
Edit: () => <SettingsIcon />
}}
/>
)
}}
我认为有一种更简单的方法可以实现您的需求。试试这个:
导入您选择的 icon
组件并使用 Edit
键定义对象以覆盖默认图标:
import Settings from "@material-ui/icons/Settings";
const tableIcons = {
Edit: () => <Settings />
};
然后使用你的MT组件的icons
道具:
<MaterialTable
columns={tableColumns}
data={data}
title="Material Table - change edit icon & tooltip "
icons={tableIcons}
localization={{
body: {
editTooltip: "Custom edit tooltip"
}
}}
// other props..
/>
如上所示,使用 localization to set the label you need. This a sandbox 和一个工作示例,祝你好运!
我想在 material-table 中设置 属性 editable 时看到不同的图标和工具提示,但我找不到方法。我知道有可能覆盖一个组件,但没有任何效果。像这样的东西可能...
components={{
EditRow: props => (
<MTableEditRow
{...props}
icons={{
Edit: () => <SettingsIcon />
}}
/>
)
}}
我认为有一种更简单的方法可以实现您的需求。试试这个:
导入您选择的 icon
组件并使用 Edit
键定义对象以覆盖默认图标:
import Settings from "@material-ui/icons/Settings";
const tableIcons = {
Edit: () => <Settings />
};
然后使用你的MT组件的icons
道具:
<MaterialTable
columns={tableColumns}
data={data}
title="Material Table - change edit icon & tooltip "
icons={tableIcons}
localization={{
body: {
editTooltip: "Custom edit tooltip"
}
}}
// other props..
/>
如上所示,使用 localization to set the label you need. This a sandbox 和一个工作示例,祝你好运!