gpt4 book ai didi

twitter-bootstrap - 使用 react-bootstrap 扩展表内的行

转载 作者:行者123 更新时间:2023-12-03 23:22:46 24 4
gpt4 key购买 nike

我正在尝试使用 react-bootsrap 做出类似的 react : http://www.bootply.com/T0v2NlXryW

我现在的 react 代码是这样的,但不起作用:

<Table>
<thead>
<tr>
<th>Job Name</th>
<th>Description</th>
<th>Provider Name</th>
<th>Region</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr data-toggle="collapse" data-target="#demo1" className="accordion-toggle">
<td>OBS Name</td>
<td>OBS Description</td>
<td>hpcloud</td>
<td>nova</td>
<td> created</td>
</tr>
<tr>
<td colspan="12" className="hiddenRow">
<div className="accordian-body collapse" id="demo1">
<h1>Hi from the hiddenRow</h1>
</div>
</td>
</tr>
</tbody></Table>

表格显示正确,但单击时行不展开。

最佳答案

<table class="table table-condensed" style="border-collapse:collapse;">
<thead>
<tr>
<th>#</th>
<th>Date</th>
<th>Description</th>
<th>Credit</th>
<th>Debit</th>
<th>Balance</th>
</tr>
</thead>
<tbody>
<tr onClick={this.onClickHandler}>
<td>1</td>
<td>05 May 2013</td>
<td>Credit Account</td>
<td class="text-success">$150.00</td>
<td class="text-error"></td>
<td class="text-success">$150.00</td>
</tr>
<tr >
<td colspan="6" class="hiddenRow"><div class="collapse" id="demo1"> Demo Content1 </div> </td>
</tr>
</tbody>
</table>

private onClickHandler(e: React.MouseEvent<HTMLTableRowElement>) {
const hiddenElement = e.currentTarget.nextSibling.firstChild.firstChild as HTMLElement;
hiddenElement.className.indexOf("collapse in") > -1 ? hiddenElement.classList.remove("in") : hiddenElement.classList.add("in");
}

关于twitter-bootstrap - 使用 react-bootstrap 扩展表内的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37689983/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com