how to centralize the title of a datatable?

how to centralize the title of a datatable?

vicvilvicvil Posts: 5Questions: 1Answers: 0
edited May 2023 in Free community support

How can I centralize the title that appears when printing the datatable? since this appears on the left side.
To display the table, I do it this way, entering text before it.

{
                    extend: 'print',
                    header: 'true',
                    text: '<img src="img/printer.png"/>',
                    titleAttr: 'Imprimir',
                    className: 'btn btn-info',
                    
                    title:'Listado de Clientes',
                        
                    
                    customize: function(window) {
                        <% List<datos_empresa> empresas; 
                        empresas = empresa;
                        String nombre = empresas.get(0).getNombre();
                        String dir = empresas.get(0).getDireccion();
                        String comu = empresas.get(0).getComuna();
                        String fono = empresas.get(0).getTelefono();
                        String mail = empresas.get(0).getEmail();
                        %>
                        $(window.document.body).children().eq(0).before('<p><%=nombre%></p>');
                        $(window.document.body).children().eq(1).before('<p>Dirección: <%=dir%></p>');
                        $(window.document.body).children().eq(2).before('<p>Comuna: <%=comu%></p>');
                        $(window.document.body).children().eq(3).before('<p>Fono: <%=fono%></p>');
                        $(window.document.body).children().eq(4).before('<p>Email: <%=mail%></p>');
                        
                      }
                }

Replies

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    The title should be centred as shown in this example.

    If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Colin

  • vicvilvicvil Posts: 5Questions: 1Answers: 0

    Thanks, the solution was the following, in case it helps someone else:

    $(window.document.body).find('h1').css('text-align', 'center');

Sign In or Register to comment.