【发布时间】:2020-03-30 18:12:52
【问题描述】:
我在 jquery 3.3.1 中使用最新的 DataTables.js。
这是表数据结构
<table id="table_id" class="display">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Data 1</td>
<td>Row 1 Data 2</td>
</tr>
<tr>
<td>Row 100 Data 1</td>
<td>Row 2 Data 2</td>
</tr>
<tr>
<td>Row 11 Data 1</td>
<td>Row 2 Data 2</td>
</tr>
</tbody>
</table>
应该对第 1 行进行排序
to row 1, row 11, row 100
or row 100, row 11, row 1
但确实如此
row 1, row 100, row 11
或
row 11, row 100, row 1
这是 javascript 中的正常排序行为, 什么也不正确。
有什么想法吗?
【问题讨论】:
-
当然,您的行已按词法(按字母顺序)排序。如果您要附加您的 jQuery 代码,我可能会建议您更改哪些内容来修复它。
-
你的javascript代码是什么?
-
您似乎想根据嵌入在某些文本中的数值进行排序。这看起来与这个问题非常相似:Datatables sorting - how to ignore text in column?。这有帮助吗?
-
我使用 Datatables js 示例中的默认设置。所以它只是jquery加载函数调用。请看我的回答。
标签: javascript sorting datatables