How to add an action to the API?
How to add an action to the API?
lenamtl
Posts: 265Questions: 65Answers: 1
I'm looking to add this hack to my code
This can be a temporary fix for colvis, responsive export when using visible selector.
I'm referring to this post https://github.com/DataTables/Responsive/issues/90
buttons: [
{
name: 'print',
extend: 'print',
exportOptions: {
columns: [':visible:not(.not-export-col):not(.hidden)'],
},
action: function(e, dt, button, config) {
responsiveToggle(dt);
$.fn.DataTable.ext.buttons.print.action(e, dt, button, config);
responsiveToggle(dt);
}
},
]
I just don't know where to put the toggle action toggle code
I believe that need to be on datatables,js but not sure where and what is the syntax I should use.
responsiveToggle(dt) {
$(dt.table().header()).find('th').toggleClass('all');
dt.responsive.rebuild();
dt.responsive.recalc();
}
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You should be able to put that function just about anywhere. As long as it can be called from the action method, then its find. You could make it a global function for example.
Allan
Ok I finally put the code in datatables.js
otherwise I was getting errors.
This is working ok for now, thanks