【问题标题】:Get the row index of bootstrap table in click without using jquery在不使用jquery的情况下点击获取引导表的行索引
【发布时间】:2017-01-27 09:13:13
【问题描述】:

我的 react 项目中有一个引导表。我想获取我单击的行的索引。我想做这样的事情 onclick = {this.handleClick} 并且在 handleClick 函数中我想获取行的索引。有没有可能做到。大多数可用的解决方案都使用 jquery 显示所有内容,我不想使用 Jquery。我只想使用javascript来做到这一点。这是我的桌子

<Table className='flags-table' responsive hover>
                                    <thead>
                                        <tr>
                                            <th> </th>
                                            <th> Time In </th>
                                            <th> Time Out </th>
                                            <th> Type </th>
                                            <th> Category </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        {
                                            FLAGS_LIST.map((x,i)=> (
                                                <tr key={i}>
                                                    <td> <div className='red-box'></div> </td>
                                                    <td> {x.time_in} </td>
                                                    <td> {x.time_out} </td>
                                                    <td> {x.type} </td>
                                                    <td> {x.category} </td>
                                                </tr>
                                            ))  
                                        }
                                    </tbody>
                                </Table>

【问题讨论】:

    标签: javascript reactjs bootstrap-table react-bootstrap-table


    【解决方案1】:

    你可以使用这样的代码:

    onclick = {this.handleClick.bind(this, i)}; 
    

    handleClick 应该这样声明:

    var handleClick = function(i) {
    console.log("key of row", i)
    ...
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-26
      • 2021-10-29
      • 1970-01-01
      • 2013-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多