Error: Unable to automatically determine field from source.

Error: Unable to automatically determine field from source.

mikducmikduc Posts: 22Questions: 6Answers: 0

I am receiving the error - Unable to automatically determine field from source. - on a check box in my table. I looked into the editor.inline method but I'm not sure how to implement or if that is even the problem - the referenced by the checkbox matches the database field.

Below is the table definition I am using and the field in question is SEL_REC. Interestingly, the database is updating properly from the checkbox even though the error is raised.

Any help with this would be greatly appreciated.

//*************************************************************************
// Begin Selected Formula(s) table
//*************************************************************************
editorSelected = new $.fn.dataTable.Editor( {
    ajax: {
        url: "ssp_SampleLookupSelectedFormulas.php",
        data: {
            userID: changedUserID
        },
   }, 
    table: "#SampleLookupSelectedFormulasTable",
        formOptions: {
            inline: {
                onBlur: 'submit'
            }
        }, 
        fields: [

            {label: "Sel",
                 name:  "SEL_REC",
                 attr: {maxlength: 1,
                        style:"width:10px; text-align:center"}
            },
        ]
} );

// Activate an inline edit on click of a table cell
$('#SampleLookupSelectedFormulasTable').on( 'click', 'tbody td:not(:first-child)', function (e) {
    editorSelected.inline( this,{onBlur:"submit"} );
} );

//** Select checkbox function
$('#SampleLookupSelectedFormulasTable').on( 'change', 'input.selectFormCheckboxValue', function () {

    var rowSelected =  tableSelected.row( $(this).closest('tr') );

    if($(this).prop('checked')){
        editorSelected
            .edit( rowSelected.node(), false )
            .set( 'SEL_REC', 'Y' )
            .submit();
    } else {
        editorSelected
            .edit( rowSelected.node(), false )
            .set( 'SEL_REC', 'N' )
            .submit();
    };

} );

var tableSelected = $('#SampleLookupSelectedFormulasTable').DataTable( {
    bLengthChange: false,
    pageLength: 15,
    dom: 'RlBfrtip',
    fixedHeader: true,
    iDisplayLength: 15,
    sPaginationType: 'full_numbers',
    bSort: false,
    searching: false,
    autoWidth: false,
    order: [[1, 'asc']], 

    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(2)").css( "text-align", "center" );
        $(row).find("td:eq(3)").css( "text-align", "center" );
        $(row).find("td:eq(6)").css( "text-align", "center" );
    },

    ajax: {
            url: "ssp_SampleLookupSelectedFormulas.php",
            data: {
                userID: changedUserID
            }
       }, 
    columns: [
        // **Select checkbox
        { className: 'selectFormCheckbox',
          "render": function ( data, type, full, meta ) {
            if(full.SEL_REC == 'N'){    
                        return '<input type="checkbox"  class="selectFormCheckboxValue">'
                }else{
                        return '<input type="checkbox"  class="selectFormCheckboxValue" checked>'
                }
             }// End - "render": function ( data, type, full, meta )   
        }, 
        { data: "fmt_sample", editField: "SAMPLE_NUM" },            // formula number
        { data: "location", editField: "LOC_ID" },                  // location
        { data: "APE_CODE" },                                       // status
        { data: "CUST_NAME" },                                  // customer
        { data: "DESCRIPTION" },                                    // description
        { data: "archive_date_fmt", editField: "ARCHIVE_DATE" } // archive date
    ],
    keys: {
       columns: [ 0 ],
         keys: [ 9 ],
         editor: editorSelected,
         editOnFocus: true,
    },                 
    select: {
        style:    'os',
        selector: 'td:first-child'
    }
} );//END .dataTable
//*************************************************************************
// End Selected Formula(s) table
//*************************************************************************

Replies

  • tangerinetangerine Posts: 3,054Questions: 24Answers: 357
    edited April 30

    That error is explained in the docs.
    https://datatables.net/manual/tech-notes/11
    although you may have already checked - I see you are using "editField".

  • colincolin Posts: 12,093Questions: 0Answers: 2,054

    You may also need to define the type as checkbox - see this example as it appears to be doing what you're trying to achieve.

    Colin

Sign In or Register to comment.