Error in JS with Datatables adding in savestate

Error in JS with Datatables adding in savestate

airmasterairmaster Posts: 72Questions: 15Answers: 2

Here is my code.

If you open the HTML document I have attached. It errors out in Chrome and FF.

jquery.js

jQuery.readyException = function( error ) {
    window.setTimeout( function() {
        throw error;
    } );
};

Firefox error

TypeError: g[a.order[b][0]] is undefined

Chrome error

Uncaught TypeError: Cannot read property '_ColReorder_iOrigCol' of undefined

I can make the error go away sometimes, removing options, such as one of the below

                responsive: true

                colReorder: true

                order: [1, 'asc']

                stateSave: true

Its pretty odd. Any thoughts?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,298Questions: 26Answers: 4,769
    edited October 2019 Answer ✓

    You have:

                $('#index').DataTable({
                    fixedHeader: true,
                    responsive: true,
                    colReorder: true,
                    orderCellsTop: true,
                    stateSave: true,
                    order: [1, 'asc']
                });
    

    Your order option is incorrect. The docs state this:

    The order must be an array of arrays, each inner array comprised of two elements:

    It should look like this order: [[1, 'asc']]. Here is your updated example:
    http://live.datatables.net/hajamaju/1/edit

    Kevin

  • airmasterairmaster Posts: 72Questions: 15Answers: 2

    Thank you so much!

    Now that you mention it, I remember seeing that, but I didn't make the connection, or double check the syntax of that, which is my fail.

This discussion has been closed.