我遇到了jQueryDataTableСolReorder扩展的问题。在控制台我得到错误然后我拖动标题:
未捕获的TypeError:b.getAttribute不是函数
这是我的代码:
$(document).ready(function() {
$('#excel').DataTable( {
stateSave: true,
colReorder: {
reorderCallback: function () {
console.log( 'callback' );
}
}
} );
} );
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://cdn.datatables.net/1.10.8/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/colreorder/1.2.0/js/dataTables.colReorder.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.8/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/colreorder/1.2.0/css/colreorder.dataTables.min.css">
<table id="excel" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>name</th>
<th>number</th>
<th>address</th>
<th>city</th>
<th>country</th>
<th>lastname</th>
</tr>
</thead>
<tfoot>
<tr>
<th>name</th>
<th>number</th>
<th>address</th>
<th>city</th>
<th>country</th>
<th>lastname</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Haroldas</td>
<td>444</td>
<td>address</td>
<td>eee</td>
<td>f</td>
<td>r</td>
</tr>
<tr>
<td>Tom</td>
<td>999</td>
<td>rrr</td>
<td>tttt</td>
<td>3</td>
<td>r</td>
</tr>
<tr>
<td>Ted</td>
<td>333</td>
<td>kkk</td>
<td>null</td>
<td>4</td>
<td>r</td>
</tr>
</tbody>
</table>
答案 0 :(得分:4)
<强>原因强>
DataTables 1.10.8存在问题#623,导致控制台出现以下错误: TypeError:row.getAttribute不是jquery.dataTables.js的函数。< / p>
<强>解强>
使用DataTables 1.10.9而不是1.10.8。
<强>样本强>
$(document).ready(function() {
$('#excel').DataTable( {
stateSave: true,
colReorder: {
reorderCallback: function () {
console.log( 'callback' );
}
}
} );
} );
&#13;
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/colreorder/1.2.0/js/dataTables.colReorder.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/colreorder/1.2.0/css/colreorder.dataTables.min.css">
<table id="excel" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>name</th>
<th>number</th>
<th>address</th>
<th>city</th>
<th>country</th>
<th>lastname</th>
</tr>
</thead>
<tfoot>
<tr>
<th>name</th>
<th>number</th>
<th>address</th>
<th>city</th>
<th>country</th>
<th>lastname</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Haroldas</td>
<td>444</td>
<td>address</td>
<td>eee</td>
<td>f</td>
<td>r</td>
</tr>
<tr>
<td>Tom</td>
<td>999</td>
<td>rrr</td>
<td>tttt</td>
<td>3</td>
<td>r</td>
</tr>
<tr>
<td>Ted</td>
<td>333</td>
<td>kkk</td>
<td>null</td>
<td>4</td>
<td>r</td>
</tr>
</tbody>
</table>
&#13;