+1 vote
3.8k views
in Jquery by (1.3k points)
How can we add auto numbering column to a Jquery datatable?

1 Answer

0 votes
by
$(document).ready(function() {
    var t = $('#example').DataTable( {
        "columnDefs": [ {
            "searchable": false,
            "orderable": false,
            "targets": 0
        } ],
        "order": [[ 1, 'asc' ]]
    } );
 
    t.on( 'order.dt search.dt', function () {
        t.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
            cell.innerHTML = i+1;
        } );
    } ).draw();
} );

Related questions

0 votes
1 answer 4.0k views
+1 vote
1 answer 10.3k views
asked May 11, 2017 in Jquery by Jasna
0 votes
1 answer 16.9k views
0 votes
0 answers 3.2k views
asked Nov 15, 2017 in Modules by HenryRoger (820 points)
0 votes
2 answers 5.9k views
asked Jul 17, 2018 in General by anonymous
...