How print row number sequence?

How print row number sequence?

fabiolg82fabiolg82 Posts: 3Questions: 0Answers: 0
edited July 2013 in General
I need print row number sequence in datatable.

As like:

Page 1
1 - content
2 - content
3 - content

Page2
4 - content
5 - content

How I do?

Replies

  • sarirotisariroti Posts: 2Questions: 0Answers: 0
    edited July 2013
    Hi fabiolg82,

    you can try this :
    $('#yourtableid').dataTable({
    fnCreatedRow: function (nRow, aData, iDataIndex) {
    var rowNumber = oTableDetails.fnSettings()._iDisplayStart + (iDataIndex + 1);
    $('td', nRow).first().html(rowNumber);
    }
    });

    [quote]you can change this part [code]$('td', nRow).first().html(rowNumber);[/code] if you dont what use first()
    to [code]$('td:eq(0)', nRow).html(rowNumber);[/code][/quote]

    hope it helps :D
  • sarirotisariroti Posts: 2Questions: 0Answers: 0
    actually i forgot to add this in front :

    [code] var oTableDetails = $('#yourtableid').dataTable({
    fnCreatedRow: function (nRow, aData, iDataIndex) {
    var rowNumber = oTableDetails.fnSettings()._iDisplayStart + (iDataIndex + 1);
    $('td', nRow).first().html(rowNumber);
    }
    });
    [/code]
This discussion has been closed.