在我的Jquery dataTable中,row.add
不起作用,并且抛出一个错误,说添加函数未定义。错误信息如下:
Uncaught TypeError: Cannot read property 'add' of undefined
html
<table id="example" class="display" 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>
</table>
<button id="addRow">Add new row</button>
javascript
$(document).ready(function() {
var counter = 1;
var prntTable = $('#example').dataTable( {
"aoColumns" : [
{"bSearchable" : false},
{"bSearchable" : true},
{"bSearchable" : true}
],
"sPaginationType" : "full_numbers"
} );
$('#addRow').on( 'click', function () {
prntTable.row.add( [
counter +'.1',
counter +'.2',
counter +'.3'
] ).draw();
counter++;
} );
$('#addRow').click();
} );