0

DataTable paging procedure not showing continuous index numbers...! Now am showing 10 items per page, For the first page the Data-table serial numbering generates correctly from 1-10.. But every pages shows from 1 to 10 numbering, need to display continuous numbering from the second page, like 11,12... Am using the following code for Datatable.

Any help would be appreciable,

Thank you

<script>

            $(document).ready(function(){
                var t = $("#table_details").DataTable({

                    "pagingType" : "full_numbers",
                    "processing" : true,
                    "searching"  : true,
                    "serverSide" : true,
                    "ajax" :{"url" : "../dataTable/serversideContacts.php",
                             "type": "post",
                             "data": { "uid" :'.$uid.',"gid" :'.$group_id.',"sid" :'.$site_id.'},

                            },

                    "columnDefs": [ {"searchable": false,"orderable": false,"targets": [0,3,4]} ],
                    "order": [[ 1, "asc" ]],
                    "language": {
              "info": "Showing page _PAGE_ of _PAGES_"
                          }

                });

                t.on( "order.dt search.dt processing.dt", function (){ 

                    t.column(0,{ search:"applied", order:"applied" }).nodes().each( function (cell, i) 
                    {cell.innerHTML = i+1; });
                }).draw();
            });
        </script>
Tijo John
  • 686
  • 1
  • 9
  • 20

2 Answers2

2

Answer is based on the following: Alert the page no. on jQuery dataTables page change event

(assuming per page = 10)

dTable.on( 'order.dt search.dt processing.dt page.dt', function () {
    dTable.column(1, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
        cell.innerHTML = i+1;
        var info = table.page.info();
        var page = info.page+1;             
        if (page >'1') { 
            hal = (page-1) *10;  // u can change this value of ur page
            cell.innerHTML = hal+i+1;
        } 
    } );
} ).draw(); 

Hope this helps.

Community
  • 1
  • 1
t10
  • 21
  • 2
0

For DataTables >= 1.10.4,

"fnCreatedRow": function (row, data, index) {
                $('td', row).eq(0).html(index + 1);
            }

hope this will help :)

saadk
  • 1,243
  • 14
  • 18