如何使用jQuery获取Bootstrap DataTable的当前页码

时间:2016-09-20 03:22:28

标签: jquery laravel-4 datatables

我想获取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}

       ],

    });
}

1 个答案:

答案 0 :(得分: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);

我希望这就是你想要的。请关注链接文档以获取更多详细信息。