首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >排除row事件中的单列

排除row事件中的单列
EN

Stack Overflow用户
提问于 2019-07-02 03:22:04
回答 1查看 245关注 0票数 2

我正在使用React-Bootstrap-Table-2,并使用它们的rowEvents函数来使行可以单击以转到另一个页面。但是,我需要从该行事件中排除其中一列,因为它有一个"status“开关,而onClick函数优先于该开关,所以我不能再切换它。

我尝试过使用columnIndex,但我不确定如何实现才能从row事件中删除它。示例:我有五列,我只希望row事件跨越其中的四列,而不是最后一列。

代码语言:javascript
复制
  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事件中完全排除。

EN

回答 1

Stack Overflow用户

发布于 2020-07-29 00:22:03

代码语言:javascript
复制
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}`)
      }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56841317

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档