2016-09-20 170 views
0

我想獲取Bootstrap dataTable的當前頁碼。所以在我編輯或刪除數據後,它將返回到它所在的頁面。如何使用jQuery獲取Bootstrap DataTable的當前頁碼

function deleteID(searchs){ 
$('#tblAccount').dataTable().fnDestroy(); 
$('#tblAccount').dataTable({ 
    "sDom": 'rtp', 
    "bServerSide": true, 
    "sAjaxSource": "ajax-accounts?type=Delete&search="+searchs, 
    "lengthMenu": [[ 8, 5], [ 10, 25,50,"ALL"]], 
    "autoWidth" : false, 
    "aoColumnDefs": [ 
     { "aTargets": [ 0 ], "bSortable": false}, 
     { "aTargets": [ 1 ], "bSortable": false}, 
     { "aTargets": [ 2 ], "bSortable": false}, 
     { "aTargets": [ 3 ], "bSortable": false} 

     ], 

    }); 
} 

回答

0

您可以使用page.info()獲取所有頁面相關信息。

用法:

var table = $('#tblAccount').dataTable({ 
    "sDom": 'rtp', 
    "bServerSide": true, 
    "sAjaxSource": "ajax-accounts?type=Delete&search="+searchs, 
    "lengthMenu": [[ 8, 5], [ 10, 25,50,"ALL"]], 
    "autoWidth" : false, 
    "aoColumnDefs": [ 
     { "aTargets": [ 0 ], "bSortable": false}, 
     { "aTargets": [ 1 ], "bSortable": false}, 
     { "aTargets": [ 2 ], "bSortable": false}, 
     { "aTargets": [ 3 ], "bSortable": false} 

     ], 

    }); 
var info = table.page.info(); 
console.log(info.page); 

我希望這是你想要的。請按照鏈接的文檔獲取更多詳細信息。

+0

感謝您的幫助 – Paul

相關問題