Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82461

Add new row

$
0
0

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.


Viewing all articles
Browse latest Browse all 82461

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>