Possible reasons for TypeError: Cannot read properties of undefined (reading 'nTable')

Possible reasons for TypeError: Cannot read properties of undefined (reading 'nTable')

aziegler3aziegler3 Posts: 47Questions: 11Answers: 1

I am using datatables 2.0.8 and editor 2.3.2. It is an upgrade from a dataTables environment that has been working well for years.
Because I couldn't make it work, I reverted to a very basic table, to see if I can make it work and still not.
1. If I run only dataTables, everything works the way it is supposed to be.
2. As soon as I introduce the Editor component, I get the error, which is, as mentioned in the title: Cannot read properties of undefined (reading 'nTable')
3. The code is reduced to its minimum expression, so I am running out of ideas to find the error.
4. The comms to the database are OK, because datatables draws all the data, it is only in Editor where the problem comes
5. If I just comment out the line table: '#example' there is no error, but then, of course, there is no editor, because it does not know what table to reference to.
6. devTools takes me to this line, as the location of the failure if (settings.nTable === dtApi.table().node())

Any ideas on where to look at?

This is the html:

    <div class="container">
        <div class="demo-html">
            <table id="example" class="display" style="width:100%">
                <thead>
                    <tr>
                        <th>Object ID</th>
                        <th>User ID</th>
                        <th>Specie</th>
                        <th>State FIP</th>
                        <th>County FIP</th>
                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <th>Object ID</th>
                        <th>User ID</th>
                        <th>Specie</th>
                        <th>State FIP</th>
                        <th>County FIP</th>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>  

This is the javascript:

$(document).ready(function() {
    var editor = new DataTable.Editor({
        ajax: '/xyz/controllers/test.php',
        table: '#example',
        fields: [
            { name: 'OBJECTID' },
            { name: 'USERID' },
            { name: 'SPECIES' },
            { name: 'STATEFIPS' },
            { name: 'COUNTYFIPS' }
        ]
    });

    $('#example').DataTable({
        ajax: '/xyz/controllers/test.php',
        columns: [
            { data: 'OBJECTID' },
            { data: 'USERID' },
            { data: 'SPECIES' },
            { data: 'STATEFIPS' },
            { data: 'COUNTYFIPS' }
        ],
        select: true
    });
});

This question has accepted answers - jump to:

Answers

Sign In or Register to comment.