gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 01:16:50 26 4
gpt4 key购买 nike

我正在使用Jquery datatables建立一个表。我需要为我拥有的每一行提供一个行索引。但是当我切换到下一页时,行索引重置为 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
]
});

最佳答案

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

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

var numStart = this.fnPagingInfo().iStart;

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

数据表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)
};
};

关于JQuery Datatables 行索引未显示相应页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12953843/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com