Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

datatable numbering

var table = $('#table').DataTable({
	data: data,
	columns: [
        {data: 'id', title: '#'}, //must have
    ],
  	columnDefs: [{
        sortable: false,
        class:    "index",
        targets:  0
    }],
    order: [[ 0, 'asc' ]],
})

table.on( 'order.dt search.dt', function () {
    table.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
      cell.innerHTML = i+1;
    });
}).draw();
 
PREVIOUS NEXT
Tagged: #datatable #numbering
ADD COMMENT
Topic
Name
7+3 =