Bootstrap Datatables not working

Bootstrap Datatables not working

themacgeniusthemacgenius Posts: 4Questions: 0Answers: 0
edited August 2013 in General
Hi,

All I'm trying to do (for right now) is duplicate the table in the example for DataTables:
http://www.datatables.net/blog/Twitter_Bootstrap_2
Example: http://www.datatables.net/media/blog/bootstrap_2/

I have it on my server here:
http://myestoretemplates.com/tts/test.php

Or - here is a JSfiddle with it too: http://jsfiddle.net/2DCzp/

And it is showing up with double rows and the pagination is not working. I'm figuring I'm doing something wrong, but the problem is - I have all the scripts I'm supposed to have, right? All the js files in the working example are included in my example.

I'd appreciate any help - thanks a ton!

Replies

  • pixelgeekpixelgeek Posts: 18Questions: 2Answers: 0
    What code are you using to initialize the table?
  • themacgeniusthemacgenius Posts: 4Questions: 0Answers: 0
    Well, I tried using
    [code]
    $(document).ready(function() {
        $('#example').dataTable( {
            "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>"
        } );
    } );[/code]

    But then I got this error:

    DataTables warning (table id = 'example'): Cannot reinitialise DataTable.

    To retrieve the DataTables object for this table, pass no arguments or see the docs for bRetrieve and bDestroy
  • themacgeniusthemacgenius Posts: 4Questions: 0Answers: 0
    What confuses me too is that this example http://www.datatables.net/media/blog/bootstrap_2/ doesn't use any (visible) code to initialize the table either, but the table is still working.
  • JowinJowin Posts: 4Questions: 0Answers: 0
    You should edit the DT_bootstrap.js and remove the last few lines which they have added in the example.

    [code]
    /* Table initialisation */
    $(document).ready(function() {
    $('#example').dataTable( {
    "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
    "sPaginationType": "bootstrap",
    "oLanguage": {
    "sLengthMenu": "_MENU_ records per page"
    }
    } );
    } );
    [/code]
  • themacgeniusthemacgenius Posts: 4Questions: 0Answers: 0
    Ok, I removed those - but that's not making any difference, whether I try initializing the table or not.
  • JowinJowin Posts: 4Questions: 0Answers: 0
    You should really try the examples and see how to properly code the html for a datatable.

    Take a look here https://github.com/Jowin/Datatables-Bootstrap3/blob/master/BS3/index.html

    Example in this http://www.datatables.net/media/blog/bootstrap_2/ initialize the code in the javascript file itself.
  • allanallan Posts: 63,506Questions: 1Answers: 10,471 Site admin
    The DataTables bootstrap integration files are here: https://github.com/DataTables/Plugins/tree/master/integration/bootstrap

    Allan
This discussion has been closed.