I want jQuery datatables to automatically create row number column in the first column like datagrid in VB.
It looks like this:
Anyone knows how to do this?
Just write a render function:
{
"data": "id",
render: function (data, type, row, meta) {
return meta.row + meta.settings._iDisplayStart + 1;
}
}
You just define an empty column in aoColumns.
Then in fnRowCallback function you just edit the column how you like. This callback is run every time new row is created.
Basicly if your first column has the row number, you could just do this in fnRowCallback:
var index = iDisplayIndex +1;
$('td:eq(0)',nRow).html(index);
return nRow;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With