Reat Material-Table: CellStyle 访问完整的 rowData 信息而不仅仅是字段
Reat Material-Table: CellStyle to access the full rowData information and not only field
我正在尝试使用 cellStyle 定义样式的单元格,但可用的信息只是与其关联的字段。但是我需要根据其他字段信息自定义。
我看到了这个拉取请求 da08676 但我仍然无法使用它。
当我做类似的事情时:
cellStyle: (value, rowData) => {
return {backgroundColor: {rowData.color}}
}
行数据未定义。
实际上可以通过传递给cellStyle的2个参数函数来解决
cellStyle: (cellValue, rowData) => {
// OPEN YOUR CONSOLE
console.log({ cellValue, rowData });
// `rowData.color` will not be defined...
// neither will `rowData.tableData.color`...
return { backgroundColor: 'purple' }
}
完整的答案可以在这里找到:https://github.com/mbrn/material-table/issues/1991#issuecomment-640131927
我正在尝试使用 cellStyle 定义样式的单元格,但可用的信息只是与其关联的字段。但是我需要根据其他字段信息自定义。
我看到了这个拉取请求 da08676 但我仍然无法使用它。
当我做类似的事情时:
cellStyle: (value, rowData) => {
return {backgroundColor: {rowData.color}}
}
行数据未定义。
实际上可以通过传递给cellStyle的2个参数函数来解决
cellStyle: (cellValue, rowData) => {
// OPEN YOUR CONSOLE
console.log({ cellValue, rowData });
// `rowData.color` will not be defined...
// neither will `rowData.tableData.color`...
return { backgroundColor: 'purple' }
}
完整的答案可以在这里找到:https://github.com/mbrn/material-table/issues/1991#issuecomment-640131927