Uncaught TypeError: Cannot read property 'replace' of undefined

Uncaught TypeError: Cannot read property 'replace' of undefined

felice1994felice1994 Posts: 1Questions: 1Answers: 0
var object = {
    "rubrica": [
        { "DT_RowId":"0","nome": "felice", "numero": "3404813560", "gruppo": "A" },
       { "DT_RowId":"1","nome": "francesca", "numero": "3489155230", "gruppo": "A" },
        { "DT_RowId": "2", "nome": "gianni", "numero": "1115559996", "gruppo": "A" },
        { "DT_RowId": "3", "nome": "raffy", "numero": "3396584712", "gruppo": "B" },
        { "DT_RowId": "4", "nome": "simona", "numero": "3926458792", "gruppo": "C" },
        { "DT_RowId": "5", "nome": "ivana", "numero": "3662974652", "gruppo": "B" },
        { "DT_RowId": "6", "nome": "clemente", "numero": "3301578963", "gruppo": "A" },
        { "DT_RowId": "7", "nome": "vincenzo", "numero": "3336669871", "gruppo": "B" },
        { "DT_RowId": "8", "nome": "raffy", "numero": "3396584712", "gruppo": "B" },
        { "DT_RowId": "9", "nome": "franca", "numero": "3926458792", "gruppo": "C" },
        { "DT_RowId": "10", "nome": "ivano", "numero": "3662974652", "gruppo": "B" },
        { "DT_RowId": "11", "nome": "dejan", "numero": "3301578963", "gruppo": "A" },
        { "DT_RowId": "12", "nome": "milito", "numero": "3396584712", "gruppo": "B" },
        { "DT_RowId": "13", "nome": "kaka", "numero": "3926458792", "gruppo": "C" },
        { "DT_RowId": "14", "nome": "serginho", "numero": "3662974652", "gruppo": "B" },
        { "DT_RowId": "15", "nome": "jesus", "numero": "3301578963", "gruppo": "A" },
        { "DT_RowId": "16", "nome": "nano", "numero": "3404256930", "gruppo": "C" }

    ]
};
var editor = new $.fn.dataTable.Editor({
    data:object.rubrica,
    table: "#tabellaRubrica",
    idSrc: "DT_RowId",
    fields: [{
        label: "Nome:",
        name: "nome"
    }, {
        label: "Numero:",
        name: "numero"
    }, {
        label: "Gruppo:",
        name: "gruppo"
    }
    ]
});



$(document).ready(function () {
    $('#tabellaRubrica').DataTable({
        dom: "Bfrtip",
        data: object.rubrica,

        columns: [
            { data: "nome" },
            {
                data: "numero",
                render: function (data, type, row) {
                    return  data.substring(0,3)+"/"+data.substring(4);
                }
            },
            { data: "gruppo" }

        ],
        
        lengthMenu: [10, 15, 20],
        ordering: true,
        searching: true,
        select:true,
        select: {
            style: 'os',
            selector: 'td:first-child'
        },
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit", editor: editor },
            { extend: "remove", editor: editor }
        ],
        order: [[0, "asc"]] 

});

});


$('#tabellaRubrica').on('click', 'tbody td:not(:first-child)', function (e) {
    editor.inline(this, {
        onBlur: 'submit'
    });
});



Answers

  • allanallan Posts: 63,831Questions: 1Answers: 10,518 Site admin

    Can you give me a little more information please? When does error occur? On initialisation of the DataTable, or when you take some action? Can you show me the back trace for the error? And ideally give me a link to the page so I can debug it directly.

    Thanks,
    Allan

This discussion has been closed.