我有一个 html 表,我正在尝试使用 tablesorter 对其进行排序(我相信我拥有最新版本)。问题是,当我对某些列进行排序时,结果排序不按顺序。具体来说,我列中的每个数字前面都有一个“R”字符(南非兰特的简写),当我对列进行排序时,它仅对第一个数字进行排序,而不是对所有数字进行排序。例如。从某种程度上来说,R100 排在 R70 之前。我的 html 看起来像这样:
<div class="table-responsive container-fluid">
<table id="BrokerTable" class="table table-bordered table-hover tablesorter">
<thead>
<tr>
<th class="col-md-2">Broker<span class="glyphicon glyphicon-chevron-down headimage"></span></th>
<th class="col-md-2">Base Transaction Fee<br> (per trade)<span class="glyphicon glyphicon-chevron-down headimage"></span></th>
<th class="col-md-2">Minimum Transaction Fee<br> (per trade)<span class="glyphicon glyphicon-chevron-down headimage"></span></th>
<th class="col-md-2">Monthly Management Fee<br> (exc. VAT)<span class="glyphicon glyphicon-chevron-down headimage"></span></th>
<th class="col-md-2">Allows limit orders<br> (required for placing orders outside of trading hours)<span class="glyphicon glyphicon-chevron-down headimage"></span></th>
<th class="col-md-2">Allows stop-loss orders<span class="glyphicon glyphicon-chevron-down headimage"></span></th>
</tr>
</thead>
<tbody>
<tr>
<td><p>28E Capital</p></td>
<td><p>0.7% : R0-R49,999<br>0.5% : R50,000-R499,999<br>0.4% : R500,000-R999,999<br>0.35% : R1,000,000+</p></td>
<td><p>R125</p></td>
<td><p>R40</p></td>
<td><p><b class="greenTick">✓</b></p></td>
<td><p><b class="greenTick">✓</b></p></td>
</tr>
<tr>
<td><p>ABSA</p></td>
<td><p>0.4%</p></td>
<td><p>R120</p></td>
<td><p>R67</p></td>
<td><p><b class="greenTick">✓</b></p></td>
<td><p><b class="redcross">✘</b></p></td>
</tr>
<tr>
<td><p>AfriFocus</p></td>
<td><p>0.5%</p></td>
<td><p>R125</p></td>
<td><p>R65</p></td>
<td><p><b class="greenTick">✓</b></p></td>
<td><p><b class="greenTick">✓</b></p></td>
</tr>
</tbody>
</table>
我的 tablesorter js 是:
<script>
$(document).ready(function() {
$("#BrokerTable").tablesorter( {sortList: [[1,0]]} );
}
);
</script>
如果有人知道如何实现这项工作,那就太好了。
jack
最佳答案
我认为实际问题是原始表排序器(v2.0.5)不执行字母数字排序。
我做了一个fork of tablesorter有很多改进。它确实执行字母数字排序。
我创建了a demo from the HTML you provided ,但里面没有 R100 或 R70,所以我添加了它们...
$(function () {
$("#BrokerTable").tablesorter({
sortList: [[1,0]],
theme: 'blue'
});
});
关于javascript - 不考虑表排序器上的 R 符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29289579/