Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35278

Uncaught TypeError: Cannot read property 'id' of null

$
0
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 },
            ]
        }
    });

Viewing all articles
Browse latest Browse all 35278

Trending Articles