[英]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.