不能初始化行重新排序插件- rowReordering不是一个函数
Cannot initialize Row Reordering plugin - rowReordering is not a function
我正在使用jQuery数据表与行重新排序插件,由于某种原因,我收到以下错误消息:
Uncaught TypeError: $(…). datatable(…)。rowReordering不是一个函数
$(document).ready(function() {
$('#demo').html('<table cellpadding="0" cellspacing="0" border="0" class="display cell-border" id="example" ></table>');
t = $('#example').DataTable({
"columns":
[
{width: "10%", "className": "ageClass", "title": "Priority", "data": "priority" },
{"className": "actionClass", "title": "Action", "data": "action" },
],
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bInfo": false,
"bAutoWidth": false,
"scrollY": "200px",
"scrollCollapse": true,
"paging": false
}).rowReordering();;
// This line is where the console says the error is
for (var i = 0; i < 10; i ++)
{
t.row.add(
{
priority: i,
action: i,
}).draw();
}
});
HTML:<div id="demo"> </div>
我只是在做下面描述的事情:https://code.google.com/p/jquery-datatables-row-reordering/wiki/Index
原始行重新排序插件与datatable 1.10不兼容。
$(selector).DataTable()
方法是在DataTables 1.10中Row Reordering addon最后一次更新之后添加的。
<解决方案/strong>
要使用rowReordering()
,您需要将表初始化为$('#example').dataTable()
,而不是$('#example').DataTable()
。
For datatable 1.10
我已经在github上分叉了附加组件,并添加了对DataTables 1.10的支持通过在评论中提出建议。
请参阅jQuery DataTables - Row Reordering文章了解更多细节和演示。
演示strong>
$(document).ready( function () {
var table = $('#example').DataTable({
"createdRow": function( row, data, dataIndex ) {
$(row).attr('id', 'row-' + dataIndex);
}
});
for(var i = 1; i <= 100; i++){
table.row.add([
i,
i + '.2',
i + '.3',
i + '.4',
i + '.5',
i + '.6'
]);
}
table.draw();
table.rowReordering();
} );
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>jQuery DataTables</title>
<link href="//cdn.datatables.net/1.10.7/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
<script src="https://code.jquery.com/ui/1.9.2/jquery-ui.min.js"></script>
<script src="http://mpryvkin.github.io/jquery-datatables-row-reordering/1.2.3/jquery.dataTables.rowReordering.js"></script>
</head>
<body>
<table id="example" class="display" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
</tbody>
</table>
</body>
</html>
相关文章:
- 创建一个类似链接的按钮,并通过Javascript函数打开一个新的弹出窗口
- 将函数的上下文应用于javascript变量
- 如何在JavaScript中将字符串转换为函数引用
- 用嵌套函数和默认函数定义函数
- 使用 jQuery 的 .on 函数如何获取事件的原始元素
- 无法导出函数expressjs/requestjs中的变量
- 函数参数中的数据与指定变量之间的任何性能差异
- JQuery合并了keyup和focusout两个函数
- ES6构造函数返回基类的实例
- 监视函数从服务返回不起作用,但作用域函数起作用
- 我可以在json对象中添加一个函数吗
- AngularJS:我可以跳过函数参数回调吗
- 如何使jQuery插件函数可调用以供独立使用,而不在集合上操作
- JavaScript数组排序(函数)用于对表行进行排序,而不是排序
- jquery点击函数select&取消选择
- 拨打'父亲'函数形式a'儿童'ReactJS中的组件
- Node.js v6.2.0类扩展不是函数错误
- 比较从函数和生成的日期对象
- jQuery中是否内置了任何字符串格式化函数
- 不能初始化行重新排序插件- rowReordering不是一个函数