Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

Cannot read property 'canReturnSubmit' of null

$
0
0

I am attempting to add client-side validation to my editor script and I am receiving the error below.

Not sure what I am missing .

Uncaught TypeError: Cannot read property 'canReturnSubmit' of null
at HTMLDocument.<anonymous> (dataTables.editor.min.js:78)
at HTMLDocument.dispatch (jquery-current.min.js:3)
at HTMLDocument.q.handle (jquery-current.min.js:3)

var editor;
$(document).ready(function() {
    editor = new $.fn.dataTable.Editor( {
        ajax: "ssp_AllergenReviewManagement.php",
        table: "#allergenTable",
           fields: [{label: "Location",
                     name:  "ELOC",
                     type:  "display",
                    },
                    {label: "Formula",
                     name:  "EFORM",
                     type:  "display",
                    },
                    {label: "Formula Description",
                     name:  "EDESC",
                     type:  "display",
                    },
                    {label: "Pack Size",
                     name:  "EPACK",
                     type:  "display",
                    },
                    {label: "Developed For",
                     name:  "EDEV",
                     type:  "display",
                     },
                     {label: "Exclusive",
                      name:  "EEXC",
                      type:  "display",
                     },
                     {label: "Proprietary",
                      name:  "EPRO",
                      type:  "display",
                     },
                     {label: "Total",
                      name:  "ETOTEG",
                      type:  "display",
                     },
                     {label: "Quantity",
                      name:  "ETOTQY",
                      type:  "display",
                     },
                     {label: "Percent",
                      name:  "EPERCT",
                      type:  "display",
                     },
                     {label: "Allergen",
                      name:  "EALGRN",
                      type:  "display",
                     },
                     {label: "Reviewed",
                      name:  "ELOOKO",
                      attr: {maxlength:1,
                             style: "height:20px; width:20px",}
                     },
                     {label: "Reviewed By",
                      name:  "EUSER",
                      type:  "display",
                     },
                      {label: "Reviewed On",
                       name:  "EDATE",
                       type:  "display",
                      },
                 ]
    } );

    $('#allergenTable').on( 'click', 'tbody td:not(:first-child)', function (e) {
        editor.inline( this,{onBlur:"submit"} );
     } );

    editor.on( 'preSubmit', function ( e, o ) {
        if ( o.data.ELOOKO === '' ) {
            this.error('ELOOKO', 'Review Flag Can Not Be Blank');
            return false;
        }
        else if ( o.data.ELOOKO !== 'Y' ) {
            this.error('ELOOKO', 'Review Flag Must Be Y or N');
            return false;
        }

    } );

    $('#allergenTable').DataTable( {
        dom: "Bfrtip",
        ajax: "ssp_AllergenReviewManagement.php",
        order: [[ 1, 'asc' ]],
        iDisplayLength: "15",
        columns: [
            {
                data: null,
                defaultContent: '',
                className: 'select-checkbox',
                orderable: false
            },
            { data: "ELOC"  },
            { data: "EFORM" },
            { data: "EDESC" },
            { data: "EPACK" },
            { data: "EDEV" },
            { data: "EEXC" },
            { data: "EPRO" },
            { data: "ETOTEG" },
            { data: "ETOTQY" },
            { data: "EPERCT" },
            { data: "EALGRN" },
            { data: "ELOOKO" },
            { data: "EUSER" },
            { data: "EDATE" }
        ],
        select: {
            style:    'os',
            selector: 'td:first-child'
        },
        buttons: [
           // { extend: "create", editor: editor },
       //     { extend: "edit",   editor: editor },
           // { extend: "remove", editor: editor }
        ]
    } );
} );

Viewing all articles
Browse latest Browse all 2364

Trending Articles