I've got the following code to create a row number in jQuery Datatables:
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull){
var index = iDisplayIndexFull + 1;
$('td:eq(0)', nRow).html(index);
return nRow;
},
However, when I search for a certain value, the row numbers update. This is expected. My question is, is there anyway to make the row numbers remain the same after they are initially created?
Example:
Initial output
1 Team1
2 Team2
3 Team3
4 Team4
5 Team5
After Searching
2 Team2
5 Team5
Is this possible?
You could store the original id in
aData
:And then, you could access it later on with:
I'd set a
data
attribute on the rows initially like so: