我有DataTable
这样:
render() {
return(
<div>
<DataTable value={this.props.members} header="Members"
selectionMode="single" onSelectionChange={this.onMemberSelected}
>
<Column field='name' header='Name' sortable />
<Column field='lastName' header='Last Name' sortable />
<Column field='address' header='Address' sortable />
<Column field='country' header='Country' sortable />
<Column body={ (member, _) => {
return this.renderDeleteButton(member);
} }/>
</DataTable>
</div>
);
}
renderDeleteButton(member) {
return (
<Button
label="Delete"
onClick={ e => {
//delete member
}}
/>
);
}
onMemberSelected(e) {
//show member detail
}
当我按“删除”按钮时,它会显示成员详细信息,因为该行正在处理该事件并且调用了onMemberSelected
。
我该如何解决这个问题?
答案 0 :(得分:1)
您可以使用stopPropagation()
停止对合成事件的传播。因此,在删除按钮的事件处理程序中,您必须像这样添加它:
handleDeleteButtonClick = event => {
event.stopPropagation();
// handle click
}