Customisation of column button text
At times it can be useful to control the text that is used for the display of each button in the
colvis list. The
columnText option of
the
colvis button type provides exactly that
ability, as a callback function.
The example below shows the column number being prefixed to the column title. As this is a function, virtually any logic could be used (performing an action
only on column indexes higher than 3 for example). You also have access to the DataTables API instance, so you can use
dt.column( idx ).node() to
get the header
th/td element if needed.
- Javascript
- HTML
- CSS
- Ajax
- Server-side script
The Javascript shown below is used to initialise the table shown in this example:
$(document).ready(function() { $('#example').DataTable( { dom: 'Bfrtip', buttons: [ { extend: 'colvis', columnText: function ( dt, idx, title ) { return (idx+1)+': ')