Adding SNO column with auto increment values

Adding SNO column with auto increment values

zapkingdudezapkingdude Posts: 3Questions: 0Answers: 0

Hello folks,

I've added one table and I tried to add an auto increment table row called "SNO" for the serial number using the https://legacy.datatables.net/ref#fnRowCallback option, the code goes as:

<code>

"fnRowCallback" : function(nRow, aData, iDisplayIndex){
$("td:first", nRow).html(iDisplayIndex +1);
return nRow;
},

</code>

The serial number is coming, but the serial number is stopping at the level where the "pageLength" option is defined, i.e., I ve set "pagelength" : 4 and made rest of the data are paginated, but every page is showing SNO from only 1-4, I want the continuous numbers in all the page, any one can please help me what to do now?

Replies

  • allanallan Posts: 62,241Questions: 1Answers: 10,211 Site admin

    The rowCallback method will only be executed as each row is added to the display.

    Try this example for an alternative approach.

    Allan

This discussion has been closed.