Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
Datatables - How to adjust columnDefs - column width on certain breakpoint?

I want to manually adjust the columns of datatables on certain breakpoints. All I want is to show all the columns in responsive but only adjust the columns width. Is that possible on datatables?

Here's my example code:

<table id="test_table" align="center">
    <thead>
        <tr>
            <th>#</th>
            <th>Name</th>
            <th>Symbol</th>
            <th>Revenue</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>test name</td>
            <td>USD</td>
            <td>$21,000</td>
        </tr>
    </tbody>
</table>

<script>
    $('#test_table').DataTable({
        ordering: false,
        scrollX: true,
        lengthMenu: [[10, 25, 50], [10, 50, 100]],
        language: {
            search: '',
            searchPlaceholder: "Search...",
            info: "Showing _END_ of _TOTAL_ entries",
            lengthMenu: "<b class='mr-8'>Rows</b> _MENU_ ",
            paginate: {
                next: '<i class="fas fa-chevron-right"></i>',
                previous: '<i class="fas fa-chevron-left"></i>'
            }
        },
        columnDefs: [
            { width: "120px", targets: 0 },
            { width: "150px", targets: 1 },
            { width: "120px", targets: [2, 3] },
        ],
    });
</script>

I set my columns to a certain width using columnDefs on desktop. So what I want is to adjust it when it reaches certain breakpoints like this:

/*Breakpoint - 767px */
columnDefs: [
    { width: "40px", targets: 0 },
    { width: "60px", targets: 1 },
    { width: "90px", targets: [2, 3] },
],

Is this possible on dataTables? if yes, can you show me some examples to help me guide through it? I'm new to datatables.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda