[英]Get the row index of bootstrap table in click without using jquery
I have a bootstrap table in my react project. 我的React项目中有一个引导表。 I want to get the index of row which I click on. 我想获取我单击的行的索引。 I want to do something like this onclick = {this.handleClick} and in handleClick function I want to get the index of row. 我想执行类似onclick = {this.handleClick}的操作,并在handleClick函数中获取行的索引。 Is it possible to do it. 有可能做到这一点。 Most of the solutions available shows everything using jquery and I don't want to use Jquery. 大多数可用的解决方案都使用jquery来显示所有内容,而我不想使用Jquery。 I want to do it using just javascript only. 我只想使用javascript做它。 This is my table 这是我的桌子
<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>
You can use code like this: 您可以使用如下代码:
onclick = {this.handleClick.bind(this, i)};
and handleClick
should declare like this: 和handleClick
应该这样声明:
var handleClick = function(i) {
console.log("key of row", i)
...
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.