Set value on cell (td) with DrawCallback (server side)

Set value on cell (td) with DrawCallback (server side)

hernan84hernan84 Posts: 7Questions: 0Answers: 0
edited March 2012 in DataTables 1.9
I'm trying to set a row number on a custom column (id=8) which works until you change the page. It seems that the "$('td:eq(8)', oSettings.aoData[ oSettings.aiDisplay[i] ].nTr ).html(i+1);" line doesn't work on a page change.

[code]
"fnDrawCallback": function ( oSettings ) {
if ( oSettings.bSorted || oSettings.bFiltered )
{
for ( var i=oSettings._iDisplayStart, iLen=oSettings.fnRecordsTotal() ; i

Replies

  • hernan84hernan84 Posts: 7Questions: 0Answers: 0
    Finally I get it looking at the rows id...

    At first I realized that my for() cicle wasn't good as I had to sum the lenght and start values (oSettings._iDisplayLength + oSettings._iDisplayStart) for the cicle limit. Then I found that no matter the number of page you are the rows number start always from 0 so I had to use another counter begining in 0.

    Final code:
    [code]
    "fnDrawCallback": function ( oSettings ) {
    var k = 0;
    var total = oSettings._iDisplayLength + oSettings._iDisplayStart;

    for ( var i=oSettings._iDisplayStart, iLen=total ; i
  • hernan84hernan84 Posts: 7Questions: 0Answers: 0
    Fix: use oSettings.aiDisplay.length instead of oSettings._iDisplayLength. Avoid problems with custom filters.
This discussion has been closed.