0 votes
9 views
asked ago in Jquery by (680 points)
How can we add auto numbering column to a Jquery datatable?

1 Answer

0 votes
answered ago 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 722 views
+1 vote
1 answer 8k views
asked May 10, 2017 in Jquery by Jasna
0 votes
1 answer 1.4k views
0 votes
0 answers 1.8k views
asked Nov 14, 2017 in Modules by HenryRoger (820 points)
0 votes
2 answers 2.3k views
...