我正在使用bootstrap-table与 table-multiple-sort扩展以制作可排序的表。
在 this example当您隐藏某些列时,隐藏列的排序将被禁用。
但是,当我应用该插件时,排序仍然发生在隐藏列上。请参阅这个 JS fiddle :
<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>
如何禁用对隐藏列的排序?
最佳答案
它之所以显示是因为您尚未设置选项sortPriority
通过设置这个可以解决错误。
Check working fiddle here
你的 JS 应该是这样的
示例取自问题中给出的 jsfiddle。
$('#mainTable').bootstrapTable({
showFilter: true,
showMultiSort: true,
sortPriority: [{
"sortName": "Location",
"sortOrder": "desc"
}]
});
关于javascript - 禁用对 bootstrap-table 中的隐藏列进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32528973/