Datatable Editor Error Clicking on Action

Datatable Editor Error Clicking on Action

pedrofdspedrofds Posts: 4Questions: 2Answers: 0

I am using the Datatable CRUD is loading the data and showing the actions (New, Edit, Delete), but an error occurred below when clicking on the option:

dataTables.editor.js:21 Uncaught TypeError: Cannot read property 'oFeatures' of undefined
    at Editor.<computed>.<computed> [as _tidy] (dataTables.editor.js:21)
    at Editor.<computed>.<computed> [as create] (dataTables.editor.js:21)
    at s.action (dataTables.editor.js:21)
    at k (dataTables.buttons.min.js:16)
    at HTMLButtonElement.<anonymous> (dataTables.buttons.min.js:17)
    at HTMLButtonElement.dispatch (jquery.min.js:2)
    at HTMLButtonElement.y.handle (jquery.min.js:2)

Source code:

oUrlBase = "http://localhost:5000/";
var editor; // use a global for the submit and return data rendering in the examples
editor = new $.fn.dataTable.Editor({
    ajax: {
        create: {
            type: 'POST',
            url: oUrlBase
        },
        edit: {
            type: 'PUT',
            url: oUrlBase + '/_id_'
        },
        remove: {
            type: 'DELETE',
            url: oUrlBase + '/_id_'
        }
    },
    table: "#example",
    fields: [{
            label: 'id',
            name: 'id' /*, type: 'readonly'*/
        },
        {
            label: "Primeiro nome:",
            name: "primeiroNome"
        }, {
            label: "Sobrenome:",
            name: "sobrenome"
        }, {
            label: "E-Mail:",
            name: "email"
        }, {
            label: "Username:",
            name: "username"
        }, {
            label: "passwordNovo:",
            name: "passwordNovo"
        }, {
            label: "Perfil de acesso:",
            name: "roleName"
        }
    ]
});
$('#tablePaginacao').DataTable({
    "dom": "Bfrtip",
    "ajax": {
        url: 'http://localhost:5000/',
        "dataSrc": "",
        "headers": {
            "Authorization": "Bearer: " + localStorage.token
        }

    },
    columns: [{
            data: "id"
        },
        {
            data: "nomeCompleto"
        },
        {
            data: "email"
        },
        {
            data: "userName"
        }
    ],
    select: true,
    buttons: [{
            extend: 'create',
            editor: editor
        },
        {
            extend: 'edit',
            editor: editor
        },
        {
            extend: 'remove',
            editor: editor
        },
        {
            extend: 'collection',
            text: 'Export',
            buttons: [
                'copy',
                'excel',
                'csv',
                'pdf',
                'print'
            ]
        }
    ]
});

// Select2
$('.dataTables_length select').select2({
    minimumResultsForSearch: Infinity
});

Tks

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    Answer ✓

    Doesn't look like you defined the correct table in the Editor init code:
    table: "#example",

    Looks like the table should be #tablePaginacao.

    Kevin

  • pedrofdspedrofds Posts: 4Questions: 2Answers: 0

    Tks

This discussion has been closed.