Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!