+1 vote
3.5k 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 3.7k views
+1 vote
1 answer 10.0k views
asked May 11, 2017 in Jquery by Jasna
0 votes
1 answer 15.6k views
0 votes
0 answers 3.0k views
asked Nov 15, 2017 in Modules by HenryRoger (820 points)
0 votes
2 answers 5.6k views
asked Jul 17, 2018 in General by anonymous
...