I am currently seeking a method to add an additional custom class to the jQuery datatables filters (Records per page and Search)
These items render as follow:
<div id="DataTables_Table_0_length" class="dataTables_length">
<label>
<select size="1" name="DataTables_Table_0_length"
aria-controls="DataTables_Table_0">
<option value="10" selected="selected">10</option>
<option value="25">25</option><option value="50">50</option>
<option value="100">100</option>
</select>
records per page
</label>
</div>
and
<div class="dataTables_filter" id="DataTables_Table_0_filter">
<label>
Search: <input type="text" aria-controls="DataTables_Table_0">
</label>
</div>
Does anyone know how I can best add an additional class to each of them? Some advise would be as usual very much appreciated.
Check out http://legacy.datatables.net/styling/custom_classes. DataTables has a slightly complicated way to override the CSS classes for some of the core elements. Here's one way
$(document).ready(function() {
var extensions = {
"sFilter": "dataTables_filter custom_filter_class",
"sLength": "dataTables_length custom_length_class"
}
// Used when bJQueryUI is false
$.extend($.fn.dataTableExt.oStdClasses, extensions);
// Used when bJQueryUI is true
$.extend($.fn.dataTableExt.oJUIClasses, extensions);
$('#example').dataTable();
});
Check out a working example here: http://jsfiddle.net/k2ava/3/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With