-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Labels
Description
Hi,
I have a datatable in my project and i can't display the number of row in the first column of my table; how to get the number (position) of any row?
here's my code:
$('#myTable').datatable({
data: json,
identify: 'field1',
lineFormat: function (id, data) {
var tr = $('<tr></tr>') ;
// First <td> element, here display number of row.
tr.append('<td></td>') ;
tr.append('<td>'+data['field1']+'</td>') ;
tr.append('<td>'+data['field2']+'</td>') ;
tr.append('<td>'+data['field3']+'</td>') ;
return tr ;
}
});Consider: when delete rows using $('#myTable').datatable('delete', id); or add new rows $('#myTable').datatable('insert', json); the numbers of table rows update automatically, is there a way to do this ?.
thanks.