API giving error message

API giving error message

miltontmiltont Posts: 22Questions: 8Answers: 0

Hi Forum,

I am using a Data-table and I wanted to:
1. Fix the Header.
2. Specify which Column the Data was sorted and whether it would sort ascending or descending.

I am getting the following error message:

DataTables warning: table id=myTable - Cannot reinitialise DataTable.
For more information about this error, please see http://datatables.net/tn/3

Both of the scripts work as intended (other than the above error message).

As I have no knowledge of API's, where to place them etc, any help would be appreciated

These are the scripts I added to my HTML file:

    <!-- THIS SCRIPT MAKES THE HEADER FIXED 80 PIXELS FROM THE TOP TO ALLOW FOR THE MENU AREA--> 

        <!-- <script>
            $('#myTable').DataTable( {
            fixedHeader: {
            headerOffset: 80
             }
            } );
        </script> -->

     <!-- SCRIPT TO SPECIFY WHICH COLUMN THE SORTING STARTS AND WHAT DIRECTION -->

        <!-- <script>
            var table = $('#myTable').DataTable();

                table
                .column( '1:visible' )
                .order( 'desc' )
                .draw();
        </script> -->

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Have you followed the steps in the technical notes linked to in the error? That'll be the place to start. Please let us know what you found.

    If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    Answer ✓

    Each of your scripts initialises the same table, hence the error. You can't reinitialise a DataTable.

Sign In or Register to comment.