I'm using jQuery DataTables with Row Reordering add-on and for some reason I receive the following error message:
Uncaught TypeError: $(...).DataTable(...).rowReordering is not a function
when doing this:
$(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>
I'm just doing what is described here: https://code.google.com/p/jquery-datatables-row-reordering/wiki/Index
Original Row Reordering add-on is incompatible with DataTables 1.10.
$(selector).DataTable()
method was added in DataTables 1.10 after Row Reordering Add-on has been last updated.For DataTables 1.9
To use
rowReordering()
you need to initialize your table as$('#example').dataTable()
, not$('#example').DataTable()
.For DataTables 1.10
I have forked the add-on on github and added support for DataTables 1.10 by using suggestions in the comments.
See jQuery DataTables - Row Reordering article for more details and demonstration.