Weird Datatables warning: table id='myTable' - false

Weird Datatables warning: table id='myTable' - false

luckmattosluckmattos Posts: 3Questions: 1Answers: 0

My table is rendering fine, so why I keep getting this error:
--- Datatables warning: table id='myTable' - false ---

A searched a lot, and I'm not getting any results, anyone know something about this "false" statement?

FYI:
1. The table is rendering perfectly.
2. It goes all the way to the "initComplete" callback.

Here is my init code:

setup.table =
        $('#myTable').DataTable({
            ordering: false,
            filter: true,
            dom: 'lftipr',
            paging: true,
            responsive: true,
            ajax: {
                url: "data.json",
                type: "GET",                    
                contentType: "application/json",
                dataSrc: function ( json ) {
                    return json.data.stations[stationActive].items;
                },
                error: function(data) {
                    globalSetup.ajaxError(data);
                },
            },
            columnDefs:
            [{
                targets: 0,
                data: "itemId",
                title: "Id",
                className: "never"
            } , {
                targets: 1,
                data: "partNumber",
                title: "Partnumber",
                className: "all"
            } , {
                targets: 2,
                data: "description",
                title: "Descrição",
                className: "all"
            } , {
                targets: 3,
                data: "moq",
                title: "MOQ",
                className: "all"
            } , {
                targets: 4,
                data: "quantity",
                title: "Qtd de Peça",
                className: "all"
            } , {
                targets: 5,
                data: "autonomy",
                title: "Autonomia",
                className: "all"
            } , {
                targets: 6,
                data: "sensorId",
                title: "Endereço Sensor",
                className: "all"
            } ]
        });

My JSON:

{
    "error": "false",
    "errorCode": 0,
    "data": {
        "partNumber" : "0012345",
        "stations" : [
            {
                "number"  : 1,
                "sensors" : [1, 2, 3, 4],
                "items"   : [
                    {
                        "itemId"      : 1, 
                        "partNumber"  : 123456,
                        "description" : "descrição 1",
                        "moq"         : 70,
                        "quantity"    : 85,
                        "autonomy"    : 13,
                        "sensorId"    : 1
                    } , {
                        "itemId"      : 2, 
                        "partNumber"  : 123456,
                        "description" : "descrição 2",
                        "moq"         : 23,
                        "quantity"    : 44,
                        "autonomy"    : 55,
                        "sensorId"     : 3
                    } , {
                        "itemId"      : 3, 
                        "partNumber"  : 123456,
                        "description" : "descrição 3",
                        "moq"         : 70,
                        "quantity"    : 80,
                        "autonomy"    : 90,
                        "sensorId"    : 3
                    } , {
                        "itemId"      : 4,
                        "partNumber"  : 123456,
                        "description" : "descrição 4",
                        "moq"         : 12,
                        "quantity"    : 32,
                        "autonomy"    : 90,
                        "sensorId"    : 4
                    }
                ]
            },
            {
                "number"  : 2,
                "sensors" : [1, 2, 3, 4],
                "items"   : [
                    {
                        "itemId"      : 5, 
                        "partNumber"  : 123456,
                        "description" : "descrição 1",
                        "moq"         : 72,
                        "quantity"    : 81,
                        "autonomy"    : 33,
                        "sensorId"    : 1
                    } , {
                        "itemId"      : 6,
                        "partNumber"  : 123456,
                        "description" : "descrição 2",
                        "moq"         : 70,
                        "quantity"    : 80,
                        "autonomy"    : 90,
                        "sensorId"    : 3
                    } , {
                        "itemId"      : 7,
                        "partNumber"  : 123456,
                        "description" : "descrição 3",
                        "moq"         : 70,
                        "quantity"    : 3230,
                        "autonomy"    : 90,
                        "sensorId"    : 3
                    } , {
                        "itemId"      : 8,
                        "partNumber"  : 123456,
                        "description" : "descrição 4",
                        "moq"         : 70,
                        "quantity"    : 80,
                        "autonomy"    : 90,
                        "sensorId"    : 4
                    }
                ]
            }
        ]
    }
}

Answers

  • mrd05dmrd05d Posts: 45Questions: 6Answers: 3

    Not sure if it matters but what is setup.table? You are initiating the datatable and then storing it in a setup object?

  • luckmattosluckmattos Posts: 3Questions: 1Answers: 0

    Yes.

  • luckmattosluckmattos Posts: 3Questions: 1Answers: 0

    I actually 5 other pages just like that and they work just fine.

  • mrd05dmrd05d Posts: 45Questions: 6Answers: 3

    I would think they would load fine just when calling the table to do something you would have to reference from the object level and not just table etc. I cant really tell much more from the code provided...

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    We would need a link to a page showing the error to be able to debug it. I don't immediately see the issue from the above code. My guess is that it is something to do with the Ajax error handling, but it is impossible to say without being able to debug it.

    Allan

This discussion has been closed.