Uncaught TypeError: Cannot read property 'id' of null

Uncaught TypeError: Cannot read property 'id' of null

josh_yonojosh_yono Posts: 2Questions: 1Answers: 0

I am evaluating Editor for testing REST API to make 'create', 'edit' and 'remove' work in my environment. Create works (with an infinite pause at the end however), but both edit and remove cause the error. How can I specify id in my JS so that dataTables handles it properly behind the scene?

    var editor = new $.fn.dataTable.Editor( {
        table: '#users',
        fields: [
            //{ label: 'id',  name: 'id'  },
            //{ label: 'Username',  name: 'username'  },
        ],
        ajax: {
            create: {
                type: 'POST',
                url: '/Controller/users.json'
            },
            edit: {
                type: 'PUT',
                url: '/Controller/users/_id_.json'
            },
            remove: {
                type: 'DELETE',
                url: '/Controller/users/_id_.json'
            }
        }
    } );
    var table = $('#Group').DataTable( {
        ajax: {
            "url" : "/Controller/users/dt_list.json",
        },
        dom: 'Tfrtip',
        columns: [
            { data : 'id'},
            { data : 'username'},
        ],
        tableTools: {
            sRowSelect: "os",
            aButtons: [
                { sExtends: 'editor_create',  editor: editor },
                { sExtends: 'editor_edit',    editor: editor },
                { sExtends: 'editor_remove',  editor: editor },
            ]
        }
    });

Answers

  • josh_yonojosh_yono Posts: 2Questions: 1Answers: 0

    My bad. I specified wrong table in Editor configuration. Now everything works smoothly.

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin

    Hi,

    Good to hear you've got it working now :-)

    Allan

This discussion has been closed.