I am using the Jquery datatables to build a table. I need a row index for every row that I have. But the row index reset to 1 when I switch to the next page.
I need the row index continues from the first page last row, mean if my page size is 10, then the 2nd page first row should start with 11 and not 1.
My problem is same with this image SAMPLE.
Please help me check what wrong with my code. Thanks alot 🙂
var oTable = $('#myDataTable').dataTable({
"bServerSide": true,
"bJQueryUI": true,
"bProcessing": true,
"sAjaxSource": sAjaxPage.toString(),
"sPaginationType": "full_numbers",
"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
debugger;
var index = iDisplayIndexFull + 1;
$("td:first", nRow).html(index);
return nRow;
},
"fnServerParams": function (aoData) {
aoData.push({ "name": "pTransactionDateFrom", "value": pTransactionDateFrom });
aoData.push({ "name": "pTransactionDateTo", "value": pTransactionDateTo });
aoData.push({ "name": "pTransactionNo", "value": pTransactionNo });
},
"aoColumns": [
{
"bSort": false,
"bSearchable": false,
"bSortable": false,
"bFilter": false
},
null,
null,
null,
null,
null,
null,
null
]
});
I have found a way to solve my problem. Not the standard but it’s working. 🙂
The datatable api is http://datatables.net/plug-ins/api#fnPagingInfo