Hello, data appears in a field that I have named or called

Hello, data appears in a field that I have named or called

crisma 1997crisma 1997 Posts: 4Questions: 2Answers: 0

Hello I have a problem
.
In my stored procedure I am calling the data "user.usu_name, user.id_role, user.usu_email" so that this data can be displayed in a modal when I press edit, but this data is appearing in the table and I do not I'm calling in no time.![]

stored procedure
(https://datatables.net/forums/uploads/editor/my/0fadb4onuy7o.jpg "")

my JS

my docente list

As you can see in Acción, the data "user.usu_name, user.id_rol, user.usu_email" should not appear, but they appear

but it is supposed to be like this without those visible fields

Answers

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,771

    Unfortunately the last column's Datatables config is cutoff in your screenshot. Looks like you have columns.defaultContent set to display the buttons. But if the last column has data then that suggests you have used columns.data to define the row object to display. columns.defaultContent will be displayed only if the columns.data is not found in the row. You might need to set columns.data to null in that column, like this:

    data: null,
    

    If you still need help then please copy and paste the Datatables init code so we can see everything you have.

    Kevin

  • crisma 1997crisma 1997 Posts: 4Questions: 2Answers: 0
    edited May 2023
    var tabla_docente;
    function listar_docente() {
        tabla_docente = $("#tabla_docente").DataTable({
            "ordering": false,
            "bLengthChange": true,
            "searching": { "regex": false },
            "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
            "pageLength": 10,
            "destroy": true,
            "async": false,
            "processing": true,
            "ajax": {
                "url": "../controlador/docente/controlador_docente_listar.php",
                type: 'POST'
          
            },
            "order": [[1, 'asc']],
            "columns": [
                { "defaultContent": "" },
                { "data": "nm_documento" },
                { "data": "docente" },
                { "data": "nombre_docente" },
                { "data": "apellidos_docente" },
                {
                    "data": "sexo_docente",
                    render: function (data, type, row) {
                        if (data == 'M') {
                            return "MASCULINO";
                        } else {
                            return "FEMENINO";
                        }
                    }
                },
                { "data": "fecha_nacimiento" },
                { "data": "telefono" },
                { "data": "nombre_materia"},
                { "data": "grados" },
                { "defaultContent": "<button style='font-size:13px;' type='button' class='editar btn btn-primary'><i class='fa fa-edit'></i></button>&nbsp;<button style='font-size:13px;' type='button' class='desactivar btn btn-danger'><i class='fa fa-trash'></i></button>&nbsp;<button style='font-size:13px;' type='button' class='activar btn btn-success'><i class='fa fa-check'></i></button>" }
            ],
    
            "language": idioma_espanol,
            select: true
    
            
        });
    

    Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,771

    Do you have some code that updates the table? You have columns.defaultContent in the first column so the column should show empty strings. But the column looks like it has an index that is added. I wonder if you have some other code updating the last column.

    Please post a link to your page or a test case replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

Sign In or Register to comment.