dataTables将css类分配给分页包装器

时间:2022-12-09 14:29:41

I have a dataTable with it most basic initialization code. But, I need to assign a custom pagination css class to the pagination which appears at the bottom of the table (i want to assign Twitter bootstrap pagination class). How should I do this?

我有一个带有最基本初始化代码的dataTable。但是,我需要为表格底部出现的分页指定一个自定义分页css类(我想分配Twitter引导程序分页类)。我该怎么做?

Here is my code:

这是我的代码:

$(document).ready(function() {
                        /* Build the DataTable with third column using our custom sort functions */
                        $('#list_table').dataTable({"sPaginationType" : 'full_numbers', 'sPaging' : 'pagination'});

                    } );

2 个解决方案

#1


8  

You can use drawCallback option:

您可以使用drawCallback选项:

$(document).ready(function () {
    $('#myDataTable').DataTable({
        ...
        "drawCallback": function () {
            $('.dataTables_paginate > .pagination').addClass('pagination-sm');
        }
    });
});

#2


1  

use .addClass() method:

使用.addClass()方法:

$('yourpager').addClass('yourTwitterbootstrappaginationclass');

#1


8  

You can use drawCallback option:

您可以使用drawCallback选项:

$(document).ready(function () {
    $('#myDataTable').DataTable({
        ...
        "drawCallback": function () {
            $('.dataTables_paginate > .pagination').addClass('pagination-sm');
        }
    });
});

#2


1  

use .addClass() method:

使用.addClass()方法:

$('yourpager').addClass('yourTwitterbootstrappaginationclass');