Row Numbers with Paging / iDisplayIndexFull confusing me?
Row Numbers with Paging / iDisplayIndexFull confusing me?
The fnRowCallback documentation says that iDisplayIndexFull is:
[quote]int : The index of the data in the full list of rows (after filtering)[/quote]
That lead me to believe that I could use it to accurately create row numbers regardless of page. I have an unfiltered grid with 45 rows spread across 5 pages. I'm using the following:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"aaSorting": [[2,'desc']],
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "datasource file",
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{"bSortable": false, "aTargets": [0]},
{"sWidth": "40px", "aTargets": [0]},
{"sWidth": "180px", "aTargets": [1]},
{"sWidth": "85px", "aTargets": [2,5]},
{"sWidth": "95px", "aTargets": [3,4]},
{"sWidth": "100px", "aTargets": [6,7]}
],
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
var index = iDisplayIndexFull + 1;
$('td:eq(0)',nRow).html(index);
return nRow;
}
});
});
[/code]
Yet, each row is numbered according only to the rows shown on that page. Am I using fnRowCallback incorrectly, or could this point to an error in my datasource file with indexing?
[quote]int : The index of the data in the full list of rows (after filtering)[/quote]
That lead me to believe that I could use it to accurately create row numbers regardless of page. I have an unfiltered grid with 45 rows spread across 5 pages. I'm using the following:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"aaSorting": [[2,'desc']],
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "datasource file",
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{"bSortable": false, "aTargets": [0]},
{"sWidth": "40px", "aTargets": [0]},
{"sWidth": "180px", "aTargets": [1]},
{"sWidth": "85px", "aTargets": [2,5]},
{"sWidth": "95px", "aTargets": [3,4]},
{"sWidth": "100px", "aTargets": [6,7]}
],
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
var index = iDisplayIndexFull + 1;
$('td:eq(0)',nRow).html(index);
return nRow;
}
});
});
[/code]
Yet, each row is numbered according only to the rows shown on that page. Am I using fnRowCallback incorrectly, or could this point to an error in my datasource file with indexing?
This discussion has been closed.