Uncaught TypeError: $.fn.dataTable.Editor is not a constructor

Uncaught TypeError: $.fn.dataTable.Editor is not a constructor

khanhminhkhanhminh Posts: 10Questions: 2Answers: 0

I follow this link: https://editor.datatables.net/examples/inline-editing/simple
and got the error: Uncaught TypeError: $.fn.dataTable.Editor is not a constructor

This is my code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.6.1/css/buttons.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css">
    <link rel="stylesheet" href="https://editor.datatables.net/extensions/Editor/css/editor.dataTables.min.css">
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.1/js/dataTables.buttons.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js"></script>
    <script type="text/javascript" src="https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js"></script>
    <script>
        $(document).ready(function() {
            var editor; // use a global for the submit and return data rendering in the examples
            editor = new $.fn.dataTable.Editor( {
                table: "#example",
                fields: [ {
                        label: "First name:",
                        name: "first_name"
                    }, {
                        label: "Last name:",
                        name: "last_name"
                    }, {
                        label: "Position:",
                        name: "position"
                    }, {
                        label: "Office:",
                        name: "office"
                    }, {
                        label: "Extension:",
                        name: "extn"
                    }, {
                        label: "Start date:",
                        name: "start_date",
                        type: "datetime"
                    }, {
                        label: "Salary:",
                        name: "salary"
                    }
                ]
            } );
         
            // Activate an inline edit on click of a table cell
            $('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
                editor.inline( this );
            } );
            $('#example').DataTable( {
                data: [
                        {
                          "DT_RowId": "row_1",
                          "first_name": "Tiger",
                          "last_name": "Nixon",
                          "position": "System Architect",
                          "email": "t.nixon@datatables.net",
                          "office": "Edinburgh",
                          "extn": "5421",
                          "age": "61",
                          "salary": "320800",
                          "start_date": "2011-04-25"
                        }
                      ],
                columns: [
                    { data: null, render: function ( data, type, row ) {
                        // Combine the first and last names into a single table field
                        return data.first_name+' '+data.last_name;
                    } },
                    { data: "position" },
                    { data: "office" },
                    { data: "extn" },
                    { data: "start_date" },
                    { data: "salary", render: $.fn.dataTable.render.number( ',', '.', 0, '$' ) },
                    {
                        data: null,
                        className: "center",
                        defaultContent: '<a href="" class="editor_edit">Edit</a> / <a href="" class="editor_remove">Delete</a>'
                    }
                ]
            } );
        } );
    </script>
</head>
<body>
    <table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th></th>
                <th>First name</th>
                <th>Last name</th>
                <th>Position</th>
                <th>Office</th>
                <th width="18%">Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
    </table>
</body>

Answers

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

    Hi @khanhminh ,

    Editor is a licensable component - the path:

    https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js

    can only be use on our website for demonstration purposes.

    Have you started a trial or purchased a copy?

    Cheers,

    Colin

  • khanhminhkhanhminh Posts: 10Questions: 2Answers: 0

    Yes. I have tried to copy as website. It look like trial version.

    How can I buy this and how much price?

  • allanallan Posts: 63,195Questions: 1Answers: 10,412 Site admin

    A 15 day free trial is available for download here.

    Pricing and licensing information is also available on the Editor site.

    Allan

  • khanhminhkhanhminh Posts: 10Questions: 2Answers: 0
    edited November 2019

    So what happened after 15 days?
    Because of downloading the package which contains full features?
    Give me the reason why I have to buy licenses while everything still works with trial version

  • kthorngrenkthorngren Posts: 21,166Questions: 26Answers: 4,921

    To use the evaluation package you need to download it to your system and load it locally. It won't run when loaded from the website like this:
    <script type="text/javascript" src="https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js"></script>

    That is why you are getting the Uncaught TypeError: $.fn.dataTable.Editor is not a constructor error.

    Kevin

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

    Give me the reason why I have to buy licenses while everything still works with trial version

    After the 15 days, the trial will stop. We feel 15 days is a good time to evaluate the software and determine whether it fits your purposes.

    Colin

This discussion has been closed.