[英]How to change the border color of a single row in react-table
我知道如何更改ReactTable
object 中一行的背景颜色(代码如下)。
如何更改行边框的颜色(不是整个表格的边框)? 我尝试将以下代码中的background
替换为border-color
、 borderColor
或border
,但这些选项都不起作用——或者,我得到一个错误,或者在编译时什么也没有发生。
getTrProps={(state, rowInfo, column) => {
if(rowInfo) {
return {
style: {
background: "blue"
}
};
}
return {};
}
像这样:
getTrProps = (state, rowInfo, instance) => {
if (rowInfo) {
return {
style: {
border: rowInfo
? rowInfo.row.age >= 20
? "solid 1px black"
: "none"
: "none"
}
};
}
return {};
};
按照此操作根据 row.value 条件更改单个单元格颜色
{
Header: () => <div className="text-center font-weight-bold">Status</div>,
accessor: "selectedstatus",
className: "font",
width: 140,
Cell: (row) => (
<div
className="text-center h-6"
style={{ background: row.value === "Selected" ? "green" : "red" }}
>
{row.value}
</div>
),
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.