- I am using
ant design table
component and I have selected rows. - I want
onClick
reset selected rows. I can not find out where it stores selected rows.
JavaScriptx10101const rowSelection = {
2onChange: (selectedRowKeys, rows) => {
3this.setState({
4selectedRowsArray: [rows]
5});
6},
7};
8
9<Table rowSelection={rowSelection} columns={columns} dataSource={paymentsHistory} />
10
Any Idea how to clear selected rows
?
Advertisement
Answer
rowSelection
also takes selectedRowKeys
property that will help you control the selected rows at any point in time.
JavaScript
1
12
12
1
const { selectedRowsArray } = this.state;
2
const rowSelection = {
3
selectedRowKeys: selectedRowsArray,
4
onChange: (selectedRowKeys, rows) => {
5
this.setState({
6
selectedRowsArray: [rows]
7
});
8
},
9
};
10
11
<Table rowSelection={rowSelection} columns={columns} dataSource={paymentsHistory} />
12