因为项目用到Datatables发现在分页特别多时无法跳转到指定页,自己动手增加了#Datatables 跳转到指定页#功能,实现代码如下:

table = $('#user-table').dataTable({
"bAutoWidth": false,
"processing": true,
"serverSide": true,
"bStateSave":true,
"pagingType": "full_numbers",
"order": [[0, 'asc']],
"ajax": get_users,
"oLanguage": {
"sUrl": "/js/advanced-datatable/lang/Chinese.json"
},
"drawCallback": function( settings ) {
if ($('body').height() < document.documentElement.clientHeight) {
$('footer').css('position','fixed');
} else {
$('footer').css('position','static');
}
if ( sla_type == 1) {
table.api().column(4).visible(false);
} else {
table.api().column(4).visible(true);
}
// 核心实现:不能放到initComplete方法里,因为表格重载后跳转功能会消失
if (table.api().page.info().pages > 1) {
$("#dynamic-table_info").append('跳到 页');
}
},
"initComplete": function(settings, json) {
if ($('body').height() < document.documentElement.clientHeight) {
$('footer').css('position','fixed');
} else {
$('footer').css('position','static');
}
$('.adv-table input[type="search"]').addClass('form-control');
},
"rowCallback": function(row, data) {
$('td:eq(0)', row).attr('title', '角色权限:' + data[11]);
},
});
// datatables跳转到指定页
$("body").delegate('#jump_page', 'keyup', function(event) {
var page = Number($(this).val());
if (event.keyCode == 13 && page > 0) {
table.api().page(page - 1).draw(false);
}
});另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。