jQuery DataTables排序不起作用
jQuery DataTables sorting is not working
使用jQuery 2.1.3和DataTables 1.10.5,当我单击列上方的向上和向下箭头时,我的表不会排序。从文档中可以看出,这是最简单的示例,应该可以使用。我似乎不明白为什么不是。
我的HTML/JavaScript
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Simple Example</title>
<link rel="stylesheet" media="screen" href="/assets/css/bootstrap.min.css">
<link rel="stylesheet" media="screen" href="/assets/css/bootstrap-theme.min.css">
<link rel="stylesheet" media="screen" href="/assets/css/jquery.dataTables.css">
</head>
<body>
<table id="table-guid" class="display compact" cellspacing="0" width="100%">
<thead>
<tr>
<th>Column-1</th>
<th>Column-2</th>
<th>Column-3</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Column-1</th>
<th>Column-2</th>
<th>Column-3</th>
</tr>
</tfoot>
<tbody>
<tr id="A">
<td>A-1</td>
<td>A-2</td>
<td>A-3</td>
</tr>
<tr id="B">
<td>B-1</td>
<td>B-2</td>
<td>B-3</td>
</tr>
<tr id="C">
<td>C-1</td>
<td>C-2</td>
<td>C-3</td>
</tr>
</tbody>
</table>
<script src="/assets/js/jquery-2.1.3.min.js"></script>
<script src="/assets/js/bootstrap.min.js"></script>
<script src="/assets/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function ()
{
var table = $('#table-guid').DataTable();
});
</script>
</body>
</html>
您必须定义列数据的类型。这里的问题似乎来自连字符,它在没有的情况下工作
解决方案:JsFiddle
$('#table-guid').dataTable( {
"columnDefs": [
{ "type": "numeric-comma", targets: "_all" }
]
});
这是文档
相关文章:
- 为什么我的JavaScript堆栈排序函数不起作用
- Rubaxa可与聚合物进行排序/拖放不起作用,具体取决于显示器:
- 我在页面中使用的jQuery UI可排序项目;不起作用
- jquery中DataTables插件中的排序不起作用
- jQuery dataTables基于类型的列筛选不起作用?Img alt过滤器/排序
- 为什么这个排序函数不起作用
- 为什么这个排序功能在 Safari 中不起作用
- JavaScript排序算法不起作用 - 任何明显的我做错了
- j查询排序不起作用
- 网页按价格排序下拉菜单不起作用
- 表排序器寻呼机在调查视图上不起作用
- 为什么这种 jquery 驱动的表排序不起作用
- jQuery DataTables排序不起作用
- D3中的排序条形图不起作用
- populate中的Mongoose排序不起作用
- 表排序在IE 7中不起作用
- 使用J-query数据表,美国日期格式的自定义排序不起作用
- jQuery 表排序器排序不起作用
- 我的Javascript(用于在ul中重新排序li)在IE中不起作用
- 从 AJAX 调用的 PHP 对数组进行排序不起作用