[英]colour one row of antd table based on condition
I'm using antd table in my project. 我在我的项目中使用antd表。 I want to change the color of one row of table if IsDefaultAccount = true where IsDefaultAccount is from back end
如果IsDefaultAccount = true ,我想更改一行表的颜色,其中IsDefaultAccount来自后端
The code of the table in the index.js page is : index.js页面中表的代码是:
<Table
className="table-layout"
columns={this.state.columns}
dataSource={filteredData}
rowClassName='data-row'
bordered={true}
size={"small"}
onRowDoubleClick={ (record, index, event) => this.handleEditModal(record) }
onRowClick={(record, index, event) => this.handleRowClick(record)}
loading={this.state.loading}
pagination={{ pageSize: 14 }}
/>
Assuming that each data-item consists of a IsDefaultAccount
property: 假设每个数据项都包含
IsDefaultAccount
属性:
<Table
className="table-layout"
columns={this.state.columns}
dataSource={filteredData}
rowClassName={(record) => record.IsDefaultAccount ? 'data-row active-row' : 'data-row' }
bordered={true}
size={"small"}
onRowDoubleClick={ (record, index, event) => this.handleEditModal(record) }
onRowClick={(record, index, event) => this.handleRowClick(record)}
loading={this.state.loading}
pagination={{ pageSize: 14 }}
/>
Let me know if this works. 让我知道这个是否奏效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.