JQuery Datatables 行索引未显示相应页面

cjj*_*k88 3 indexing jquery row datatables

我正在使用Jquery 数据表来构建一个表。我需要为我拥有的每一行提供一个行索引。但是当我切换到下一页时,行索引重置为 1。我需要行索引从第一页最后一行继续,意味着如果我的页面大小是 10,那么第二页第一行应该以 11 而不是 1 开头。我的问题与此图像SAMPLE相同。请帮我检查一下我的代码有什么问题。多谢 :)

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
                    ]
});
Run Code Online (Sandbox Code Playgroud)

cjj*_*k88 5

我找到了解决我的问题的方法。不是标准,但它有效。:)

"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {

                    var numStart =  this.fnPagingInfo().iStart;

                    var index = numStart +  iDisplayIndexFull + 1;
                    $("td:first", nRow).html(index);
                    return nRow;
                },
Run Code Online (Sandbox Code Playgroud)

数据表API是http://datatables.net/plug-ins/api#fnPagingInfo

$.fn.dataTableExt.oApi.fnPagingInfo = function (oSettings) {
    return {
        "iStart": oSettings._iDisplayStart,
        "iEnd": oSettings.fnDisplayEnd(),
        "iLength": oSettings._iDisplayLength,
        "iTotal": oSettings.fnRecordsTotal(),
        "iFilteredTotal": oSettings.fnRecordsDisplay(),
        "iPage": Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength),
        "iTotalPages": Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)
    };
};
Run Code Online (Sandbox Code Playgroud)