I want to add a new row in my table via a button and I have found this code
$(document).ready(function() {
var t = $('#example').DataTable();
var counter = 1;
$('#addRow').on( 'click', function () {
t.row.add( [
counter +'.1',
counter +'.2',
counter +'.3',
counter +'.4',
counter +'.5'
] ).draw( false );
counter++;
} );
// Automatically add a first row of data
$('#addRow').click();
} );
My table has 43 columns, do I need to add a counter for each column, or can it just be left blank if that cell doesn't require a value or a unique value? Only one of my columns is mandatory, and must be unique.