1.6.2 Editor select regression

1.6.2 Editor select regression

vipsoftvipsoft Posts: 10Questions: 1Answers: 0
edited April 2017 in Free community support

Upgrading to 1.6.2, the inline editor fails on click. Getting:

Uncaught Unable to automatically determine field from source. Please specify the field name. For more information, please refer to https://datatables.net/tn/11

Code snippet:

       var editor;
        var acquirers;

        $(document).ready(function() {
            $('table.records_list').DataTable({
                ajax: {
                    url: '/acquirers.json',
                    dataSrc: function (json) {
                        acquirers = json.options._acquirer;

                        return json.data;
                    }
                },
                paging: false,
                info: false,
                columns: [
                    {
                        data: '_acquirer.name',
                        editField: 'acquirer',
                        defaultContent: ''
                    },
                ],
                initComplete: function (settings, json) {
                    $(document).trigger('initComplete.dt');
                }
            });
        });

        $(document).on('initComplete.dt', function () {
            editor = new $.fn.dataTable.Editor({
                ajax: '/acquirers.json',
                table: 'table.records_list',
                formOptions: {
                    main: {
                        submit: 'changed'
                    }
                },
                fields: [
                    {
                        label: 'Acquirer',
                        data: 'acquirer',
                        name: 'acquirer.id',
                        type: 'select',
                        options: acquirers,
                        placeholder: '',
                        placeholderDisabled: false
                    }
                ]
            });

            $('table.records_list').on('click', 'tbody td:not(".no-inline-edit")', function () {
                editor.inline(this, {
                    onBlur: 'submit'
                });
            });
        });

JSON payload:

{"data":[{"id":1,"acquirer":2,"_acquirer":{"name":"Bravo","id":2},"DT_RowId":"row_1"}],"options":{"_acquirer":[{"value":1,"label":"Alpha"},{"value":2,"label":"Bravo"},{"value":3,"label":"Charlie"}]},"files":[]}

Test URLs
* 1.6.1: https://aegisapi.com/1.6.1/
* 1.6.2: https://aegisapi.com/1.6.2/

Replies

  • vipsoftvipsoft Posts: 10Questions: 1Answers: 0

    Nevermind. Just read the changelog. =P

  • vipsoftvipsoft Posts: 10Questions: 1Answers: 0

    I changed: editField: 'acquirer', to editField: 'acquirer.id',

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    Thanks for the update. I should perhaps have highlighted that change a little more. In the majority of cases the fields.name and fields.data attributes are the same, but if they are different and you are also using columns.editField then yes, it would need a change in your code.

    Allan

This discussion has been closed.