我正在尝试将react material-table(https://github.com/mbrn/material-table)与我的项目集成。
我用了类似的东西。
<MaterialTable options={{
rowStyle: x => {
if ( x.id % 2 ) {
return { backgroundColor: "#f2f2f2" }
}
},
'headerStyle' : {
backgroundColor: 'red',
color: theme.palette.common.white
}
}}
columns={columns}
data={data}
title="New Table"
/>
但是我希望有一个通用的样式和主题
const CustomTableCell = withStyles(theme => ({
head: {
backgroundColor: theme.palette.common.black,
color: theme.palette.common.white,
},
body: {
fontSize: 14,
},
}))(TableCell);
基本上我想要像CustomMaterialTable这样的东西,这只是我的主题/风格。
if ( x.id % 2 ) {
return { backgroundColor: "#f2f2f2" }
}
由于我的表将进行排序,我希望它在自动生成的行id上而不是x.id(其中x是我的数据)。
x.tableData.id
而不是x.id
吗?