Make Wide Tables Mobile‑Friendly with DataTables Responsive Extension
Turn wide HTML tables into mobile‑friendly views with DataTables’ Responsive extension. Learn how to auto‑hide columns, expand child rows, and configure priorities for an optimal on‑screen experience.
04 Oct 2026, 20:54 UTC

Problem: Wide Tables Don’t Fit on Small Screens
When you display a data‑heavy table on a phone or tablet, the default horizontal scroll can make the content unreadable and user‑unfriendly. Developers often resort to CSS media queries or manual column hiding, which quickly becomes brittle as the table evolves.
Solution: Let DataTables Handle Responsiveness
The Responsive extension for DataTables automatically detects screen width and hides the least important columns. The hidden data is moved into a child row that the user can expand with a simple click. This keeps the table readable on any device without writing custom CSS or JavaScript.
How the Responsive Extension Works
- When the table is rendered, DataTables checks each column’s
responsivePriority(default is the column order). - Columns with the lowest priority are hidden as the viewport shrinks.
- A plus icon appears in the first column; clicking it expands a child row that contains the hidden data in a readable format.
- The extension uses a small CSS bundle that relies on Flexbox, so modern browsers (Chrome, Edge, Firefox, Safari) render the child rows smoothly.
Getting Started: Include the Files
Ensure you have the core DataTables files and the responsive add‑on. The following CDN links are for DataTables 1.10.25 and jQuery 3.6.0; adjust the versions to match your project.
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css"/>
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.2.9/css/responsive.dataTables.min.css"/>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.2.9/js/dataTables.responsive.min.js"></script>
Initialize the Table
Activate the extension by passing responsive: true when you create the DataTable. You can also set column priorities to control which columns stay visible first.
$(document).ready(function() {
$('#example').DataTable({
responsive: true,
// Optional: set priorities (lower number = higher priority)
columns: [
{ data: 'name', responsivePriority: 1 },
{ data: 'position', responsivePriority: 2 },
{ data: 'office', responsivePriority: 3 },
{ data: 'extn', responsivePriority: 4 },
{ data: 'start_date', responsivePriority: 5 },
{ data: 'salary', responsivePriority: 6 }
]
});
});
What Happens on a Small Screen?
- The table will collapse, hiding columns with the lowest priority.
- A
+icon appears in the first column of each row. - Clicking the icon expands a child row that lists the hidden data in a vertical layout.
Example: Server‑Side Processing with Responsive
When you use server‑side processing, you can still benefit from Responsive. The extension requests only the columns that are currently visible, reducing the payload size.
$('#example').DataTable({
serverSide: true,
ajax: {
url: '/api/data',
type: 'POST'
},
responsive: true,
columns: [
{ data: 'name' },
{ data: 'position' },
{ data: 'office' },
{ data: 'extn' },
{ data: 'start_date' },
{ data: 'salary' }
]
});
On mobile, the server will only receive requests for the first two or three columns, speeding up response times.
Trade‑offs & Limitations
- Footprint: The responsive JS and CSS add roughly 10 KB gzipped. On ultra‑low‑end devices, this may slightly increase load time.
- Browser Support: Flexbox is required for the child rows. Older browsers like IE 11 may not render the child rows correctly.
- Custom Styling: If your design demands a different layout for hidden data, you may need to override the default child row styles.
- Accessibility: The expand/collapse icon is a button, but you should add
aria-labelattributes if you customize the icon.
Actionable Next Steps
- Include the responsive CSS/JS in your project and initialize the table with
responsive: true. - Define
responsivePriorityvalues to control which columns stay visible on the smallest viewports. - Test the table on a real mobile device or using your browser’s device emulation to confirm that columns collapse and the child rows appear.
- If you use server‑side processing, verify that the server receives only the visible column data by inspecting the network request payload.
- For older browsers, add a fallback or polyfill for Flexbox, or consider a custom CSS solution for small screens.
- Monitor performance: use browser dev tools to check the size of the DataTables payload and the time to render the responsive child rows.
Conclusion
The DataTables Responsive extension is a lightweight, declarative way to make large tables usable on mobile devices. By simply adding a few files and a configuration option, you eliminate the need for manual column hiding and provide a consistent user experience across devices.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.