datables boostrap missing classes ?

datables boostrap missing classes ?

tschmittschmit Posts: 8Questions: 4Answers: 0

Hello,

I'm trying to setup a grid using boostrap and dataTables.
To get the same render as the sample : https://www.datatables.net/manual/styling/bootstrap-simple.html
I'm must use the following code:

$('#ttest').dataTable().addClass("table").addClass("table-striped").addClass("table-bordered");

that is some classes are missing with only $('#ttest').dataTable().

I build my package from dataTables download choosing Datables and Bootstrap 3.

Any suggestion welcome

thierry

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I don't understand what you mean by some classes are missing? Can you link to a test case showing the issue please?

    Thanks,
    Allan

  • tschmittschmit Posts: 8Questions: 4Answers: 0

    $('#ttest').dataTable()

    results in:

    <table class="dataTable no-footer">

    when expected is (according to cited sample):

    <table class="table table-striped table-bordered dataTable no-footer">

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    There is a comment in the 'view source' for that page:

        // For demo to fit into DataTables site builder...
        $('#example')
            .removeClass( 'display' )
            .addClass('table table-striped table-bordered');
    

    More generally, if you want those classes, just have them in the table. They don't need to be added by Javascript and I don't really see any benefit in doing so.

    Allan

This discussion has been closed.