How to fix $.fn.dataTable.Editor is not a constructor?

How to fix $.fn.dataTable.Editor is not a constructor?

madusankamadusanka Posts: 20Questions: 7Answers: 0

i saw many quetions regarding with this problem. but i couldn't find a solution
here is my code

async getCustomers(){
                let self = this;
                var editor;
                $(document).ready(function() {
                        editor = new $.fn.dataTable.Editor( {
                            ajax: {
                                data: function (data) {
                                    data.token = localStorage.getItem("token")
                                },
                                'url': '/api/v1/customers',
                            },
                            table: "#customer_list",
                            fields: [ {
                                label: "First name:",
                                name: "first_name"
                            },
                            ]
                        } );
                        $('#customer_list').on( 'click', 'tbody td:not(:first-child)', function (e) {
                            editor.inline( this, {
                                buttons: { label: '>', fn: function () { this.submit(); } }
                            } );
                        } );
                this.dataTable = $("#customer_list").DataTable({
                    serverSide: true,
                    dom: "Bfrtip",
                    ajax: {
                        data: function (data) {
                            data.token = localStorage.getItem("token")
                        },
                        'url': '/api/v1/customers',

                        dataFilter: function (data) {
                            var json = jQuery.parseJSON(data);
                            var response = json.data.searchResults;
                            self.customers = response.customers;
                            json.data = response.customers;
                            json.recordsFiltered = response.recordsFiltered;
                            json.recordsTotal = response.recordsTotal;
                            //console.log(1,JSON.stringify(json))
                            return JSON.stringify(json);
                        }
                    },
                    columns: [
                        {data: "id"},
                        {data: "first_name"},
                        {data: "last_name"},
                        {data: "email"},
                    ],
                    select: {
                        style:    'os',
                        selector: 'td:first-child'
                    },
                });
                $('#customer_list').DataTable().destroy();
                } );
            },

This question has an accepted answers - jump to answer

Answers

  • madusankamadusanka Posts: 20Questions: 7Answers: 0

    i'm developing vue+laravel application and in my welcome.blade file i've imported below cdns

    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
        <script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
        <script src="https://cdn.datatables.net/buttons/1.6.1/js/dataTables.buttons.min.js"></script>
        <script src="https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js"></script>
        <script src="https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js"></script>
    
  • madusankamadusanka Posts: 20Questions: 7Answers: 0

    should i purchased license?

  • colincolin Posts: 6,896Questions: 0Answers: 1,179
    Answer ✓

    Hi @madusanka ,

    It's definitely a licensed product - so you either need to initiate a 14 day trial or purchase the license. You're using the Editor file from our site, which won't work - you need to host either the trial version or the purchased version locally, see here.

    Cheers,

    Colin

  • madusankamadusanka Posts: 20Questions: 7Answers: 0

    thank you @colin

Sign In or Register to comment.