Datatables.net - Plugin options
DataTables jQuery Plugin Options – Complete Guide
In Part I of this series, we introduced the basics of the DataTables.net jQuery plugin.
The DataTables jQuery plugin provides a rich set of configuration options for sorting, paging, search, and responsive layouts. Let’s see how you can utilize these options efficiently.
CDN Links for DataTables
Add the following CSS and JS files to your project using CDN links:
Stylesheet References
https://cdn.datatables.net/responsive/2.2.1/css/responsive.dataTables.min.css
Script References
https://cdn.datatables.net/responsive/2.2.1/css/responsive.dataTables.min.css
Disable All Options
paging: false,
searching: false,
info: false
});
To display “Show entries” dropdown at the bottom of the data table
"dom": 'frtlip'
});
})
To display “Show entries” dropdown at the bottom of the data table in the same row
$('.promo-pricing-table').dataTable({
"dom": 'frtlip'
});
//lengthmenu -> add a margin to the right and reset clear
$(".dataTables_length").css('clear', 'none');
$(".dataTables_length").css('margin-right', '20px');
//info -> reset clear and padding
$(".dataTables_info").css('clear', 'none');
$(".dataTables_info").css('padding', '0');
})
To explain only drop down and remove “show entries” phrase in the data tables
"dom": 'frtlip',
language: {
sLengthMenu: " _MENU_"
}
});
//lengthmenu -> add a margin to the right and reset clear
$(".dataTables_length").css('clear', 'none');
$(".dataTables_length").css('margin-right', '20px');
//info -> reset clear and padding
$(".dataTables_info").css('clear', 'none');
$(".dataTables_info").css('padding', '0');
Changing datatables text of “Showing x of n records”
language: {
info: "Displaying _PAGE_ of _PAGES_ records"
}
});
Enable DataTables Responsive Mode
To make your table responsive, include the following assets and add the responsive class to your HTML table.
Assets
"https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js"
HTML Markup
Next, Slight changes are implemented to html. The class 'responsive' is added to table.
JavaScript Initialization
responsive: true
});
Preview – Desktop View

Preview – Responsive (Mobile) View

Like the DataTables plugin, there are many useful jQuery utilities that improve web performance. Check out this guide: How to Debug Effectively Using jQuery .
Follow us on Facebook @CreativeTechnocrayts and stay updated!
Comments
Post a Comment