【发布时间】:2015-03-18 14:17:31
【问题描述】:
我有一个这样的容量列的数据表:
<table id="datatable" class="table">
<thead> <tr> <th>N</th> <th>capa</th> </tr> </thead>
<tbody>
<tr>
<td>1</td>
<td>2 Go</td>
</tr>
<tr>
<td>2</td>
<td>1 To</td>
</tr>
<tr>
<td>3</td>
<td>320 Go</td>
</tr>
<tr>
<td>4</td>
<td>2 To</td>
</tr>
<tr>
<td>5</td>
<td>500 Go</td>
</tr>
</tbody>
</table>
<script>
$(document).ready(function() {
$('#datatable').dataTable({
'aaSorting': [],
'iDisplayLength': 50,
'aLengthMenu': [[10, 25, 50, 100, 500, -1], [10, 25, 50, 100, 500, 'Tous']]
});
});
</script>
我正在尝试对其进行排序以获得此结果:
2 Go
320 Go
500 Go
1 To
2 To
但是通过阅读排序插件文档无法弄清楚如何做到这一点。
谢谢
【问题讨论】:
-
对不起,你能弄清楚你想要达到的列排序标准是什么吗?如果要对第二列进行降序排序,则必须删除字符串“Go”或“To”之前的数字。除非您想处理和覆盖从列内容中去除数值的排序函数
-
数据表的默认排序方法只对数字进行排序,然后我得到这个结果:
1 To 2 Go 2 To 320 Go 500 Go
标签: javascript sorting datatables