I only click on the row each time, and the other lines shrink automatically. I set the breakpoint to find that the expandedRowKeys can be obtained each time, but I can still expand multiple lines, that is, I click on line a first, then line b, and line b expands, but line a still expands and does not shrink.
< hr >within the render method:
<Table
dataSource={this.state.SampleData}
rowKey={record => record.id || record.key}
columns={columns}
onChange={this.handleStandardTableChange}
pagination={this.state.pagination}
loading={this.state.loading}
expandedRowRender={(record) => { return this.state.showListDom[record.id] || null; }}
onExpand={(expanded, record) => { return this.expandFunction(expanded, record) || null; }}
expandedRowsKeys={this.state.expandedRowsKeys}
/>
< hr >
onExpand trigger:
expandFunction = (expanded, record) => {
const { showListDom } = this.state;
this.setState({
newShowList: {},
});
const keys = [];//
if (record && expanded) {
keys.push(record.id);
const param = {
modelId: record.id,
};
this.setState({
...this.state,
param: {
modelId: record.id,
},
});
this.getExpandData(param, () => {
const subList = this.state.subData.map((v) => {
return {
...v,
todo: v.status,
};
});
const dom = (
<Table
columns={this.detailsColumns}
onChange={this.handleSubTableChange}
dataSource={subList}
rowKey={subList.id}
pagination={false}
/>);
const Id = record.id;
const item = {};
item[Id] = dom;
const newItem = {};
newItem[Id] = dom;
this.setState({
showListDom: {
...showListDom,
...item,
},
expandedRowsKeys: keys,//expandedRowKeys
});
});
}
};