+1 vote
181 views
asked in Jquery by (690 points)
How can we add auto numbering column to a Jquery datatable?

1 Answer

0 votes
answered 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 850 views
+1 vote
1 answer 8k views
asked May 10, 2017 in Jquery by Jasna
0 votes
1 answer 1.6k views
0 votes
0 answers 1.9k views
asked Nov 14, 2017 in Modules by HenryRoger (820 points)
0 votes
2 answers 2.5k views
asked Jul 17, 2018 in General by anonymous
...