我正在使用React-Bootstrap-Table-2,并使用它们的rowEvents函数来使行可以单击以转到另一个页面。但是,我需要从该行事件中排除其中一列,因为它有一个"status“开关,而onClick函数优先于该开关,所以我不能再切换它。
我尝试过使用columnIndex,但我不确定如何实现才能从row事件中删除它。示例:我有五列,我只希望row事件跨越其中的四列,而不是最后一列。
const rowEvents = {
onClick: (e, row, rowIndex) => {
this.handleOfferSelection(row);
},
onMouseEnter: (e, row, rowIndex) => {
this.setState({ activeRow: rowIndex });
}
};
// Table
<BootstrapTable
{...props.baseProps}
pagination={paginationFactory()}
rowEvents={rowEvents}
rowStyle={rowStyle}
/>我只需要将最后一列从row事件中完全排除。
发布于 2020-07-29 00:22:03
onClick: (e, row, rowIndex) => {
let getCurrentCellIndex = e.target.cellIndex;
let getLastCellIndex = document.querySelector('table tr:last-child td:last-child').cellIndex
// As this event is for the hole ROW, we need to exclude last one, as we have different events there. You can exclude no matter which one, even pass it as parameter.
if (getCurrentCellIndex !== getLastCellIndex && getCurrentCellIndex !== undefined) {
console.log(`----> ${JSON.stringify(row)} |||| ${rowIndex}`)
}
}https://stackoverflow.com/questions/56841317
复制相似问题