JQuery 数据表:链接和纯文本分开排序
JQuery Datatables: Links and plain text is sorted separate
我尝试使用 JQuery 创建数据表并根据第一列对其进行排序。此列包含链接和纯文本。
JQuery 显然将它们分开排序,因此首先按字母顺序排列链接,然后按字母顺序排列纯文本下方。
如何将它们混合在一起,使每种文本格式都被认为是相同的?
我已经尝试了很多解决方案,包括列类型定义、自定义顺序定义...None 其中一些工作正常。
$(document).ready(function () {
$('#toollist').dataTable({
"iDisplayLength": 10,
"scrollY": "500px",
"scrollCollapse": true,
"lengthMenu": [5, 10, 25, 50, 100],
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.2/css/jquery.dataTables.min.css"/>
<table id="toollist" class="table display table-bordered">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="https://www.google.com">
<strong>A</strong></a></td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>
<strong>A</strong></td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>
<strong>B</strong></td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>
<a href="https://www.google.com">
<strong>B</strong></a></td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>
<a href="https://www.google.com">
<strong>C</strong></a></td>
<td>D</td>
<td>E</td>
</tr>
<tr>
<td>
<strong>C</strong></td>
<td>D</td>
<td>E</td>
</tr>
</tbody>
</table>
这是 Sharepoint 特定的字符集问题。
问题的答案在以下 Datatables 论坛提要中:
https://datatables.net/forums/discussion/43509/links-and-plain-text-are-sorted-separately#latest
不过,allan 也发布了一个非常有用的排序插件。
我尝试使用 JQuery 创建数据表并根据第一列对其进行排序。此列包含链接和纯文本。
JQuery 显然将它们分开排序,因此首先按字母顺序排列链接,然后按字母顺序排列纯文本下方。
如何将它们混合在一起,使每种文本格式都被认为是相同的? 我已经尝试了很多解决方案,包括列类型定义、自定义顺序定义...None 其中一些工作正常。
$(document).ready(function () {
$('#toollist').dataTable({
"iDisplayLength": 10,
"scrollY": "500px",
"scrollCollapse": true,
"lengthMenu": [5, 10, 25, 50, 100],
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.2/css/jquery.dataTables.min.css"/>
<table id="toollist" class="table display table-bordered">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="https://www.google.com">
<strong>A</strong></a></td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>
<strong>A</strong></td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>
<strong>B</strong></td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>
<a href="https://www.google.com">
<strong>B</strong></a></td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>
<a href="https://www.google.com">
<strong>C</strong></a></td>
<td>D</td>
<td>E</td>
</tr>
<tr>
<td>
<strong>C</strong></td>
<td>D</td>
<td>E</td>
</tr>
</tbody>
</table>
这是 Sharepoint 特定的字符集问题。 问题的答案在以下 Datatables 论坛提要中: https://datatables.net/forums/discussion/43509/links-and-plain-text-are-sorted-separately#latest
不过,allan 也发布了一个非常有用的排序插件。