引导表中的表多重排序不适用于一页中的多个表
Posted
技术标签:
【中文标题】引导表中的表多重排序不适用于一页中的多个表【英文标题】:Table-multiple-sort in boostrap-table doesn't work for multiple tables in one page 【发布时间】:2015-12-06 21:31:00 【问题描述】:我使用bootstrap-table 和扩展名table-multiple-sort。当我在一页中有两个表时(在我的情况下,第二个表在模式窗口中),在第二个表中我没有任何选择进行多重排序。
jsfiddle
html
<table ref="mainTable" className="table table-striped table-bordered table-hover" cellSpacing="0" id="mainTable" data-show-toggle="true" data-show-columns="true" data-search="true" data-pagination="true">
<thead>
<tr>
<th data-field="state" data-checkbox="true"></th>
<th data-field="Customer Name" data-halign="center"
data-align="left" data-sortable="true">Customer Name</th>
<th data-field="Location Type" data-halign="center"
data-align="left" data-sortable="true">Location Type</th>
<th data-field="Location" data-halign="center"
data-align="left" data-sortable="true">Location</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>Cap Corp</td>
<td>Main</td>
<td>Norwalk CT 06851</td>
</tr>
<tr>
<td></td>
<td>Cap Corp</td>
<td>Other</td>
<td>Norwalk CT 06851</td>
</tr>
<tr>
<td></td>
<td>Tel</td>
<td>Main</td>
<td>Slough SL1 4DX</td>
</tr>
<tr>
<td></td>
<td>Tel</td>
<td>Other</td>
<td>London W1B 5HQ</td>
</tr>
</tbody>
</table>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
<table class="table table-striped table-bordered table-hover" cellspacing="0" id="modalTable" data-click-to-select="true" data-show-toggle="true" data-show-columns="true" data-search="true" data-pagination="true">
<thead>
<tr>
<th data-field="state" data-checkbox="true"></th>
<th data-field="name">Name</th>
<th data-field="stargazers_count">Stars</th>
<th data-field="forks_count">Forks</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>ala</td>
<td>234</td>
<td>Norwalk CT 06851</td>
</tr>
<tr>
<td></td>
<td>ala</td>
<td>234</td>
<td>Norwalk CT 06851</td>
</tr>
<tr>
<td></td>
<td>ala</td>
<td>234</td>
<td>Slough SL1 4DX</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
javascript
$('#mainTable').bootstrapTable(
showFilter: true,
showMultiSort: true
);
$('#modalTable').bootstrapTable(
showFilter: true,
showMultiSort: true
);
【问题讨论】:
第二个表中某处存在笔误,导致第二个表无法排序。 Here's a working example of two sortable tables 基于您发布的内容。 【参考方案1】:您的模态表标题缺少data-sortable="true"
属性:
<thead>
<tr>
<th data-field="state" data-checkbox="true"></th>
<th data-field="Customer Name" data-halign="center"
data-align="left" data-sortable="true">Customer Name</th>
<th data-field="Location Type" data-halign="center"
data-align="left" data-sortable="true">Location Type</th>
<th data-field="Location" data-halign="center"
data-align="left" data-sortable="true">Location</th>
</tr>
</thead>
【讨论】:
以上是关于引导表中的表多重排序不适用于一页中的多个表的主要内容,如果未能解决你的问题,请参考以下文章
复选框(Icheck)限制不适用于数据表中的其他页面,仅适用于第一页