expandedRowKeys每次拿到了,却不起作用?
我每次只展开点击行,其它行自动收缩的效果,设置断点发现每次的expandedRowKeys能够拿到,但仍然能够展开多行,即先点开a行,再点开b行,b行展开,但a行仍然展开,未收缩。
render方法内:
<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}
/>
onExpand触发:
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
});
});
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
expandedRowKeys={this.state.expandedRowsKeys}
属性名写错了