如何在react-admin中更改数据网格行文本颜色?
我想为行更改文本颜色,但找不到决定。我尝试了此代码。 “颜色”不起作用,而是“背景色”工作。
export const CustomersList = props => {
const DatagridUsersProps = {
rowStyle: (record, index) => {
return {
color: "#FFCC00",
backgroundColor: (record.is_blocked || record['is_deleted']) && "silver",
};
}
};
return (
<List
{...props}
>
<ScrollingWrapper>
<Datagrid {...DatagridUsersProps}>
<TextField source="id" />
<LinkField source="first_name" />
<LinkField source="last_name" />
<EmailField source="email" />
<PhoneField source="phone" />
</Datagrid>
</ScrollingWrapper>
</List>
);
}
感谢您提供任何示例代码或链接!
I want change a text color for row, but can't find decision. I tried this code. "color" not working, but "backgroundColor" working.
export const CustomersList = props => {
const DatagridUsersProps = {
rowStyle: (record, index) => {
return {
color: "#FFCC00",
backgroundColor: (record.is_blocked || record['is_deleted']) && "silver",
};
}
};
return (
<List
{...props}
>
<ScrollingWrapper>
<Datagrid {...DatagridUsersProps}>
<TextField source="id" />
<LinkField source="first_name" />
<LinkField source="last_name" />
<EmailField source="email" />
<PhoneField source="phone" />
</Datagrid>
</ScrollingWrapper>
</List>
);
}
Thank you for any sample code or link to do that!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信您可以使用它们的 makeStyle 挂钩来覆盖组件类。使用检查元素查找组件类名称。
根据他们的文档 https://marmelab.com/react-admin/doc /3.19/主题.html
希望这有帮助
I believe you can override component class using their makeStyle hooks. Find the component class name using inspect element.
as per their documentation here https://marmelab.com/react-admin/doc/3.19/Theming.html
hope this helps
为了解决这个问题,我使用了样式组件的组合,useStyles 和 rowStyle for Datagrid。
StyledEmailField.js:
UseStales.js:
List.jsx:
For decide this problem i used combination of styled components, useStyles and rowStyle for Datagrid.
StyledEmailField.js:
UseStales.js:
List.jsx: