+1 vote
606 views
in Jquery by (730 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 1.2k views
+1 vote
1 answer 8.3k views
asked May 11, 2017 in Jquery by Jasna
0 votes
1 answer 2k views
0 votes
0 answers 2k views
asked Nov 15, 2017 in Modules by HenryRoger (820 points)
0 votes
2 answers 3k views
asked Jul 17, 2018 in General by anonymous
...