Editor issues after recent upgrade.

Editor issues after recent upgrade.

mikducmikduc Posts: 31Questions: 8Answers: 0

We recently upgraded from DataTables 1.10.19 to DataTables 2.0.7 as well as DataTables Editor v1.6.5 to DataTables Editor v2.3.2. Since the upgrade I am experiencing issues with updating a check box that was working prior to the upgrade. Along with this we also upgraded from PHP 7.4 to 8.0.

The error is: Uncaught Unable to automatically determine field from source. Please specify the field name. For more information, please refer to https://datatables.net/tn/11. I have reviewed my script, and the field appears to be fully defined.

Any ideas? Let me know if I need to send any code snippets.

Thanks,

Replies

  • kthorngrenkthorngren Posts: 21,188Questions: 26Answers: 4,925

    The place to start is to review the troubleshooting steps at the link provided in the error:
    https://datatables.net/manual/tech-notes/11

    If that doesn't help then posting your Datatables and Editor configs and the field causing the error would be good. Better is a link to your page replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • mikducmikduc Posts: 31Questions: 8Answers: 0

    I have built a test case to demonstrate the checkbox issue, but I am having trouble returning any rows. If you could review my test to see why it is not working, then maybe we can resolve the checkbox issue.

    https://live.datatables.net/rulejufa/1/edit

    Thanks,

  • kthorngrenkthorngren Posts: 21,188Questions: 26Answers: 4,925

    The data needs to point to the data object in memoDataSet, for example: data: memoDataSet.data,.

    There isn't a data option for Editor.

    Here is the updated example:
    https://live.datatables.net/rulejufa/3/edit

    The Unable to automatically determine field error doesn't occur when checking/unchecking the checkbox. The only thing I can think of is to make sure you have td:not(:first-child) as part of your selector for inline editing, like you have in the test case.

    Kevin

  • mikducmikduc Posts: 31Questions: 8Answers: 0

    Kevin, it is interesting that the test case works fine but my production script produces an error. The only difference between the two is the Ajax I am using to retrieve data. The script is updating the database, but I would like to eliminate the error if possible. I am including my production code snippet if that helps.

                    editorMemo = new $.fn.dataTable.Editor( {
                        ajax: {
                            url: "ssp_SampleFormulaMemoDisplay.php",
                            data: {
                                formNum: form_num_element.value, 
                                formRev: form_rev_element.value, 
                                locID: locid_element.value,
                                editMode: 'Y'
                            }
                       }, 
                        table: "#MemoTable",
                            formOptions: {
                                inline: {
                                    onBlur: 'submit'
                                }
                            }, 
                            fields: [
    
                                {label: "Del",
                                     name:  "DEL_REC",
                                     attr: {maxlength: 1,
                                            style:"width:50px; text-align:center"}
                                },
                            ]
                    } );
    
                    // Activate an inline edit on click of a table cell
                    $('#MemoTable').on( 'click', 'tbody td:not(:first-child)', function (e) {
                        editorMemo.inline( this,{onBlur:"submit"} );
                    } );
                    $( 'input', editorMemo.node() ).on( 'focus', function () {
                        this.select();
                    } );
    
                    //** Delete checkbox function
                    $('#MemoTable').on( 'change', 'input.deleteMemoCheckboxValue', function () {
    
                        var rowMemo =  tableMemo.row( $(this).closest('tr') );
    
                        if($(this).prop('checked')){
                            editorMemo
                                .edit( rowMemo.node(), false )
                                .set( 'DEL_REC', 'Y' )
                                .submit();
                        } else {
                            editorMemo
                                .edit( rowMemo.node(), false )
                                .set( 'DEL_REC', 'N' )
                                .submit();
                        };
    
                    } );
    
                    var tableMemo = $('#MemoTable').DataTable( {
                        pageLength: 5,
                        iDisplayLength: 5,
                        order: [[4, 'desc']], 
    
                        rowCallback: function( row, data, index ) {
                            $(row).find("td:eq(0)").css( "text-align", "center" );
                            $(row).find("td:eq(1)").css( "text-align", "center" );
                            $(row).find("td:eq(3)").css( "text-align", "center" );
                            $(row).find("td:eq(4)").css( "text-align", "center" );
                            $(row).find("td:eq(5)").css( "text-align", "center" );
                            $(row).find("td:eq(6)").css( "text-align", "center" );
                        },
    
                        ajax: {
                                url: "ssp_SampleFormulaMemoDisplay.php",
                                data: {
                                    formNum: form_num_element.value, 
                                    formRev: form_rev_element.value, 
                                    locID: locid_element.value,
                                    editMode: 'Y'
                                }
                           }, 
                        columns: [
                            // **Delete checkbox
                            { className: 'deleteMemoCheckbox',
                              "render": function ( data, type, full, meta ) {
                                if(full.DEL_REC == 'N'){    
                                            return '<input type="checkbox"  class="deleteMemoCheckboxValue">'
                                    }else{
                                            return '<input type="checkbox"  class="deleteMemoCheckboxValue" checked>'
                                    }
                                 }// End - "render": function ( data, type, full, meta )   
                            }, 
                            { data: "TYPE_ID" },            // memo type
                            { data: "MEMO" },               // memo text
                            { data: "CREATED_BY" },         // created by
                            { data: "CREATION_STAMP" },     // created date
                            { data: "UPDATE_BY" },          // updated by
                            { data: "UPDATE_STAMP" }        // updated date
                        ],
                        keys: {
                           columns: [ 0 ],
                             keys: [ 9 ],
                             editor: editorMemo,
                             editOnFocus: true,
                        },                 
                        select: {
                            style:    'os',
                            selector: 'td:first-child'
                        }
                    } );//END .dataTable
    

    Thank, Mike

  • allanallan Posts: 63,266Questions: 1Answers: 10,424 Site admin

    Can you PM me a link to the page so I can debug it?

    Allan

Sign In or Register to comment.