Inline Editor for local datatable - always throws errors on cell update/save

Inline Editor for local datatable - always throws errors on cell update/save

East Gippsland WaterEast Gippsland Water Posts: 2Questions: 1Answers: 0

I get the following error regardless how I process my code. At this time this plugin is no value to me if it can't even do the basics. Hoping some one can help. Trying with a small ( but data - structure relevant example )

var concern_editor;
var tableID = 'table#concerns_table';

    concern_editor = new $.fn.dataTable.Editor({
            table: tableID,
            idSrc: 'id',
            fields: [{ label: 'Is concerned?', name: 'concern_affected' },
                     { label: 'Comments', name: 'concern_comments' }
            ]
        });

        $(tableID).DataTable({
            'paging': false,
            'searching': false,
            'ordering': false,
        'select': true,
        'columns': [{ data: 'id', title: 'id' },
                { data: 'description', title: 'description' }, 
                { data: 'concern_affected', title: 'Is Affected?' },
                { data: 'concern_comments', title: 'Comments' }  ],
            'data': [
                { id: '1', description: " example 1", concern_affected: 'Yes', concern_comments: ' ' },
                { id: '2', description: " example 2", concern_affected: 'Yes', concern_comments: ' ' },
                { id: '3', description: " example 3", concern_affected: 'Yes', concern_comments: ' ' },
                { id: '4', description: " example 4", concern_affected: 'No', concern_comments: ' ' }
            ],
       });

        $(tableID).on('click', 'tbody td:not(:first-child)', function (e) {
            concern_editor.inline(this);
        } );

 <script src="/Scripts/jquery-3.3.1.js"></script>
<script src="/Scripts/jquery-ui.js"></script>
<script src="/Scripts/popper.min.js"></script>
<script src="/Scripts/bootstrap.min.js"></script>
 <script src="/Scripts/Theme/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="/Scripts/Theme/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script src="/Scripts/Theme/datatables.net/js/dataTables.select.min.js"></script>
<script src="/Scripts/Theme/datatables.net/js/dataTables.rowReorder.min.js"></script>
<script src="/Scripts/Theme/datatables.net/js/dataTables.buttons.min.js"></script>
<script src="/Scripts/editor/js/dataTables.editor.js"></script>

Table renders, inline editor works by allowing me to make changes, but on save/enter the below error always occurs.

Error:
Unhandled exception at line 10, column 125796 in .../editor/js/dataTables.editor.js
0x800a138f - JavaScript runtime error: Object expected

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946
    edited July 2018 Answer ✓

    I created a test case for you here:
    http://live.datatables.net/qiyiwida/1/edit

    Your JS code seems to work without generating that error. The example is using the latest (nightly) versions of the Datatables code. Maybe you have an old version of Datatables or Editor.

    What versions are you running?

    Maybe you need to update to the latest release versions using the Download builder.

    Kevin

  • East Gippsland WaterEast Gippsland Water Posts: 2Questions: 1Answers: 0

    Many thanks kevin. Looks like a library issue was causing the issue. I have decided to use the download build solution which resolved the problem beautifully.

    Bonus - less library calls now :smile: )

This discussion has been closed.