How can I use a custom action in a extended button?
How can I use a custom action in a extended button?

Hi:
I have a "colvis" extended button, and I would like to do some custom actions when use clicks in each of the columns to make them visible or invisible:
{
extend: 'colvis',
action: function ( e, dt, node, config ) {
// do some stuff
}
}
But, if I do this, the stuff is executed, but the "colvis" feature disappear :-(
Is there any way to do extra things when use clicks in each column to make it visible/invisible ?
Thank you
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Listen for the
buttons-action
event on that button to do whatever it is you need to do. The issue is that by providing anaction
function you are overriding the default, which is to show the collection. Often you can workaround that by calling the original action method, but that is actually really tricky with thecolvis
button due to the way it is defined.buttons-action
is the way to do this one.Allan
Actually - when I sat down and looked at it again I had a thought - you can trigger the collection action: http://live.datatables.net/qavatemi/2/edit .
Allan
Thank you Allan !!! It worked ...
is there any event for the clicks of each column name shown in the modal box of colvis ?
if not, I can trigger with $('button.buttons-columnVisibility').on('click', ...
but if there's any cleaner way ... ;-)
Hi @skiiiks ,
You can also use the
buttons-action
as Allan suggested above, see here.Cheers,
Colin
PERFECT ! thank you !