My code is with the problem below, it started when I started using mysql

My code is with the problem below, it started when I started using mysql

Elias RibeiroElias Ribeiro Posts: 3Questions: 1Answers: 0

dataTables.editor.js:10 Uncaught TypeError: (intermediate value)[(intermediate value)(intermediate value)(intermediate value)] is not a function
at dataTables.editor.js:10
at dataTables.editor.js:10
at dataTables.editor.js:10
at dataTables.editor.js:10
(anonymous) @ dataTables.editor.js:10
(anonymous) @ dataTables.editor.js:10
(anonymous) @ dataTables.editor.js:10
(anonymous) @ dataTables.editor.js:10

datatables.min.js:14 jQuery.Deferred exception: $.fn.dataTable.Editor is not a constructor TypeError: $.fn.dataTable.Editor is not a constructor
at HTMLDocument.<anonymous> (http://localhost/gestor/js/table.ufs.js?versao=7:13:15)
at j (https://cdn.datatables.net/v/dt/jq-3.2.1/moment-2.18.1/jszip-2.5.0/pdfmake-0.1.32/dt-1.10.16/b-1.5.1/b-colvis-1.5.1/b-flash-1.5.1/b-html5-1.5.1/b-print-1.5.1/r-2.2.1/sc-1.4.4/sl-1.2.5/datatables.min.js:14:29999)
at k (https://cdn.datatables.net/v/dt/jq-3.2.1/moment-2.18.1/jszip-2.5.0/pdfmake-0.1.32/dt-1.10.16/b-1.5.1/b-colvis-1.5.1/b-flash-1.5.1/b-html5-1.5.1/b-print-1.5.1/r-2.2.1/sc-1.4.4/sl-1.2.5/datatables.min.js:14:30313) undefined
r.Deferred.exceptionHook @ datatables.min.js:14
k @ datatables.min.js:14
setTimeout (async)
(anonymous) @ datatables.min.js:14
i @ datatables.min.js:14
add @ datatables.min.js:14
(anonymous) @ datatables.min.js:14
Deferred @ datatables.min.js:14
then @ datatables.min.js:14
r.fn.ready @ datatables.min.js:14
(anonymous) @ table.ufs.js?versao=7:11
(anonymous) @ table.ufs.js?versao=7:186

datatables.min.js:14 Uncaught TypeError: $.fn.dataTable.Editor is not a constructor
at HTMLDocument.<anonymous> (table.ufs.js?versao=7:13)
at j (datatables.min.js:14)
at k (datatables.min.js:14)

FILE Config.php

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Database user / pass
*/
$sql_details = array(
"type" => "Mysql", // Database type: "Mysql", "Postgres", "Sqlserver", "Sqlite" or "Oracle"
"user" => "gsyst796_elias2", // Database user name
"pass" => "xxxxxx", // Database password
"host" => "br.hostgator.com.br", // Database host
"port" => "3306", // Database connection port (can be left empty for default)
"db" => "gsyst796_gestor", // Database name
"dsn" => "", // PHP DSN extra information. Set as charset=utf8 if you are using MySQL
"pdoAttr" => array() // PHP PDO attributes array. See the PHP documentation for all options
);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Links for library
*/
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/jq-3.2.1/moment-2.18.1/jszip-2.5.0/pdfmake-0.1.32/dt-1.10.16/b-1.5.1/b-colvis-1.5.1/b-flash-1.5.1/b-html5-1.5.1/b-print-1.5.1/r-2.2.1/sc-1.4.4/sl-1.2.5/datatables.min.css">
<link rel="stylesheet" type="text/css" href="css/generator-base.css">
<link rel="stylesheet" type="text/css" href="css/editor.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.2.5/css/select.dataTables.min.css">
<script type="text/javascript" charset="utf-8" src="https://cdn.datatables.net/v/dt/jq-3.2.1/moment-2.18.1/jszip-2.5.0/pdfmake-0.1.32/dt-1.10.16/b-1.5.1/b-colvis-1.5.1/b-flash-1.5.1/b-html5-1.5.1/b-print-1.5.1/r-2.2.1/sc-1.4.4/sl-1.2.5/datatables.min.js"></script>
---> library Licensed

<!--script type="text/javascript" charset="utf-8" src="js/dataTables.editor.js"></script-->
<script type="text/javascript" charset="utf-8" src="https://cdn.datatables.net/select/1.2.5/js/dataTables.select.min.js"></script>
<script type="text/javascript" charset="utf-8" src="https:cdn.datatables.net/plug-ins/1.10.15/dataRender/datetime.js"></script>

Answers

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Hi,

    Are you able to give me a link to the page showing the issue please? It sounds like it might be a Javascript loading order issue, or perhaps the trial version of Editor is still being used?

    Allan

  • Elias RibeiroElias Ribeiro Posts: 3Questions: 1Answers: 0

    The program is in Portuguese (Brazil)

    Digite o Token para Liberar o Sistema ( Enter the Token to Release the System )

    Enter the Token: 7e6c3f779cfc724a392e4e2d7da3b94a
    Press the (Liberar) release button to enter

    Refresh is page (F5)

    Cadastro -> Tabelas -> Estados
    Register -> Tables -> States

    Does not show table

    Code:

    HTML

    <div class='container'>
        <h1>
            Cadastro <span>UFs</span>
        </h1>
        <table class='display' id='ufs' style='width: 98%;'>
            <thead>
                <tr>
                    <th style='width: 2%;'></th>
                    <th style='width: 25%;'>UF</th>
                    <th style='width: 25%;'>Descrição</th>
                </tr>
            </thead>
        </table>
    </div>
    

    JS

    (function($){
    var editor;
    $(document).ready(function() {
    
        var editor = new $.fn.dataTable.Editor( {
            ajax: 'php/table.ufs.php',
            table: '#ufs',
            multiEditable: false,
            i18n: {
                create: {
                    button: "Novo",
                    title:  "Incluido um novo registro",
                    submit: "Criar"
                },
                edit: {
                    button: "Editar",
                    title:  "Modificando o registro",
                    submit: "Atualizar"
                },
                remove: {
                    button: "Excluir",
                    title:  "Excluindo o registro",
                    submit: "Excluir",
                    confirm: {
                        _: "Deseja excluir as %d linhas de registros?",
                        1: "Deseja excluir o registro?"
                    }
                },
                error: {
                    system: "Ocorreu um erro, contate o administrador do sistema"
                },
                datetime: {
                    previous: 'Anterior',
                    next:     'Próximo',
                    months:   [ 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Julio', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro' ],
                    weekdays: [ 'Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab' ]
                }
            },        
            fields: [
                {
                    "label": "UF:",
                    "name": "cd_uf"
                },
                {
                    "label": "Descrição:",
                    "name": "ds_uf"
                },
                {
                    "label": "UF IBGE:",
                    "name": "uf_ibge",
                    "type": "readonly"
                },
                {
                    "label": "ICMS:",
                    "name": "icms"
                },
                {
                    "label": "ST:",
                    "name": "st"
                },
                {
                    "label": "CFOP:",
                    "name": "cfop"
                }              
            ]             
        } );
    
        // Activate an inline edit on click of a table cell
        $('#ufs').on( 'click', 'tbody td:not(:first-child)', function (e) {
            editor.inline( this );
        } );
    
        editor.on( 'preSubmit', function ( e, o, action ) {
            if ( action !== 'remove' ) {
                var cd_uf = this.field( 'cd_uf' );
                if ( ! cd_uf.isMultiValue() ) {
                    if ( ! cd_uf.val() ) {
                        cd_uf.error( 'Digite o código UF!' );
                    }else if ( cd_uf.val().length < 2 ) {
                        cd_uf.error( 'Digite um código valido!' );
                    }
                }
    
                var ds_uf = this.field( 'ds_uf' );
                if ( ! ds_uf.isMultiValue() ) {
                    if ( ! ds_uf.val() ) {
                        ds_uf.error( 'Digite o descrição do UF!' );
                    }else if ( ds_uf.val().length < 3 ) {
                        ds_uf.error( 'Digite uma descrição valida!' );
                    }else if ( ds_uf.val().length > 50 ) {
                        ds_uf.error( 'O tamanho máximo para a descrição é 50' );
                    }
                }
    
                // If any error was reported, cancel the submission so it can be corrected
                if ( this.inError() ) {
                    return false;
                }
            }
        } );
    
    
        var table = $('#ufs').DataTable( {
            dom: 'Bfrtip',
            ajax: 'php/table.ufs.php',
            order: [[ 0, 'asc' ]],
            columns: [
                {
                    data: null,
                    defaultContent: '',
                    className: 'select-checkbox',
                    orderable: false
                },
                {
                    "data": "cd_uf"
                },
                {
                    "data": "ds_uf"
                }    
            ],
            select: {
                select: true,
                style:    'os',
                selector: 'td:first-child'            
            },      
            lengthChange: false,
            buttons: [
                { extend: 'create', editor: editor },
                { extend: 'edit',   editor: editor },
                { extend: 'remove', editor: editor },
                {
                    extend: 'collection',
                    text: 'Exportar',
                    autoClose: true,
                    buttons: [
                        'copy',
                        'excel',
                        'csv',
                        'pdf',
                        'print'
                    ]
                }
            ],
            language: {
                "sEmptyTable": "Nenhum registro encontrado",
                "rows": "%d linhas selecionadas",
                "sInfo": "Mostrando de _START_ até _END_ de _TOTAL_ registros",
                "sInfoEmpty": "Mostrando 0 até 0 de 0 registros",
                "sInfoFiltered": "(Filtrados de _MAX_ registros)",
                "sInfoPostFix": "",
                "sInfoThousands": ".",
                "sLengthMenu": "_MENU_ resultados por página",
                "sLoadingRecords": "Carregando...",
                "sProcessing": "Processando...",
                "sZeroRecords": "Nenhum registro encontrado",
                "sSearch": "Pesquisar",
                "oPaginate": {
                    "sNext": "Próximo",
                    "sPrevious": "Anterior",
                    "sFirst": "Primeiro",
                    "sLast": "Último"
                },
                "oAria": {
                    "sSortAscending": ": Ordenar colunas de forma ascendente",
                    "sSortDescending": ": Ordenar colunas de forma descendente"
                },
                select: {
                    rows: {
                        _: "Selecionado %d linhas",
                        0: "Clique na linha para selecionar um registro",
                        1: "Selecionado um registro"
                    }
                }                
            }
        });
    });
    
    }(jQuery));
    

    PHP

    <?php
    
    /*
     * Editor server script for DB table usuarios
     * Created by http://editor.datatables.net/generator
     */
    
    // DataTables PHP library and database connection
    include( "lib\DataTables.php" );
    
    // Alias Editor classes so they are easy to use
    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Options,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate,
        DataTables\Editor\ValidateOptions;
    
    Editor::inst( $db, 'tb_uf', 'cd_uf' )
        ->fields(
            Field::inst( 'cd_uf' ),
            Field::inst( 'ds_uf' ),
            Field::inst( 'uf_ibge' ),
            Field::inst( 'icms' ),
            Field::inst( 'st' ),
            Field::inst( 'cfop' )      
        )
        ->process( $_POST )
        ->json();
    
  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Hi,

    I'm not sure if you had intended to include a link to the page above or not, but I don't see one. Are you able to give me a link to the page so I can follow your instructions?

    Send me a PM by clicking my forum user name and then the "send message" button if you want to not make it public.

    Thanks,
    Allan

  • Elias RibeiroElias Ribeiro Posts: 3Questions: 1Answers: 0
    edited June 2018

    I'm sorry, I'll send in your forum

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Thanks. I can't find the code that is inserting the js/table.utf.js file as a <script> tag. Can you show me how that is happening please?

    My guess is that the table is being rendered after that file is loaded. So when the file is loaded, there is nothing for it to enhance.

    Allan

This discussion has been closed.