Thanks to Andrew James, I was able to write the row's index to the row's title property. Now I have this code that does it after each sorting but I was looking for a way to beautify the code
If no one can, then this may serve as a solution for others, because it works
Cheers
var table = $(".table").DataTable(...);
//jquery code to rewrite the row index number to each row title after sorting
function writeRowIndex() {
var rowIdx = 1;
table.rows().every(function (rowIdx) {
$(this.node()).attr('title', rowIdx);
rowIdx++;
});
}
//call the function on loading the page;
writeRowIndex();
//calling function after each sorting event
var headers = table.columns().header().toArray();
$(headers).on('click', function () {
writeRowIndex();//call existing function
});