How to use html elements within a table with Datatable

Asked

Viewed 39 times

0

How to configure Datatables to compile html code?

inserir a descrição da imagem aqui

The intention was to leave the text "Active" in green or color that indicates success according to the theme.

Table Initialization Code:


const altbl = $('#trimestre-table').DataTable({
                processing: true,
                serverSide: true,
                ajax: '{!! route('datatables.trimestre') !!}',
                columns: [
                    {data: 'id', name: 'id'},
                    {data: 'descricao', name: 'descricao'},
                    {data: 'ini', name: 'ini'},
                    {data: 'fin', name: 'fin'},
                    {data: 'status', name: 'is_active'},
                    {
                        defaultContent: "<a href='#!' class='m-r-15 text-muted' id='edit' data-toggle='tooltip' data-placement='top' title='' data-original-title='Editar'><i class='icofont icofont-ui-edit'></i></a>"
                            + "<a href='#!' class='text-muted' id='delete' data-toggle='tooltip' data-placement='top' title='' data-original-title='Deletar'><i class='icofont icofont-delete-alt'></i></a>",
                        className: 'action-icon text-center'
                    }
                ],
                language: {
                    "sEmptyTable": "Nenhum registro encontrado",
                    "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"
                    }
                },
                initComplete: function (settings, json) {
                    $('[data-toggle="tooltip"]').tooltip();
                },
                order: [[0, "desc"]],
            });

  • Place console.log(json); in the Function of initComplete and see what it shows.

  • Should I look for something specific? I don’t understand...

  • It will return a JSON, correct? See what shows in this JSON the value where this has span?

  • Displays data but with html entities

  • In the database tb is with html entities?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.