Datatable editor buttons not working

Datatable editor buttons not working

fabiofacirfabiofacir Posts: 3Questions: 3Answers: 0

I'm trying to run an inline editable table with the following code:

var editor;
                editor = new $.fn.dataTable.Editor( {

                    table: '#' + this.datatable_id,
                    idSrc: "id",
                    fields: [ {
                        label: "Email:",
                        name: "email"
                    }, {
                        label: "First:",
                        name: "first"
                    }, {
                        label: "Last:",
                        name: "last"
                    }, {
                        label: "Gender:",
                        name: "gender"
                    }, {
                        label: "Phone:",
                        name: "phone"
                    }
                    ]
                } );
                $('#' + this.datatable_id).on( 'click', 'tbody td:not(:first-child)', function (e) {
                    editor.inline( this );
                } );

            
            
            
            
                $.fn.dataTable.ext.errMode = 'none';
                this.datatable = $('#' + this.datatable_id).DataTable({
                    dom: 'lrtip',
                    "paging": false,
                    "info": false,
                    "scrollY": "480px",
                    "scrollCollapse": true,
                    "columns": this.columns[columns_index],

                    "language": {
                        "emptyTable": "Faz upload do csv/excel para ver o conteúdo."
                    },
                    buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor }
        ]
                });

                var columns = this.columns[columns_index];
                var columns_parsed = [];
                columns.forEach(function (element) {
                    columns_parsed.push(element["title"]);
                });
                this.datatable_columns = columns_parsed;


                $('#' + this.datatable_id).on('error.dt', function (e, settings, techNote, message) {
                    console.log("error:" + message);
                    this.datatable.clear();
                });

I'm getting the following error:
Cannot extend unknown button type: create

I have all the files has I've built it using https://datatables.net/download/.

If I remove this:

````
buttons: [
{ extend: "create", editor: editor },
{ extend: "edit", editor: editor },
{ extend: "remove", editor: editor }
]

```

It works ok.

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @fabiofacir,

    That would suggest it isn't seeing the Editor source files. Do you have a trial or a license copy of the library? Can you confirm you're including it, please.

    Cheers,

    Colin

This discussion has been closed.