I've been using datatables for awhile now and just came across the new buttons extension. In my project I have a LOT of buttons which do various things, but at the time had to hand code all of it. So, I am playing around with the buttons extension to see if there would be any benefit to changing my code. Few questions :
Using a simple example such as :
"buttons": [
{
text: 'Select All',
className: 'btn-success',
action: function ( e, dt, node, config ) {
alert( 'Button activated');
}
},
{
text: 'Deselect All',
className: 'btn-success',
action: function ( e, dt, node, config ) {
alert( 'Button activated');
}
},
{
text: 'Refresh',
className: 'btn-success',
action: function ( e, dt, node, config ) {
alert( 'Button activated');
}
}
],
Buttons show fine and work great, BUT I notice they are all 'grouped together' with the parent class having 'dt-buttons btn-group'. Can we turn on/off the btn-group class? In my case there are times where I would like them grouped and others when I don't.
Finally, aside from being able to define and reuse buttons what benefit is there to using this method instead of the old way :
//load in the dom
$("#dtButtons").html('<button id="dtSelect" type="button" class="btn btn-success">Select All</button>');
//do something
$('#dtSelect').on('click', function () {
...some action
});
Lastly, the copy, print, csv, colvis, etc is what intrigued me. At the moment I only offer a csv download and did all the creation/downloading of it by hand rather than using tabletools. Problem is I use server-side and I noticed right off the bat all of those solutions only work for what is actually shown in the table just as I figured. Is there no way to add functionality for server-side here? We already have the ajax
options defined so I would think it would be possible to pass the last table params (search, sort, etc) and get results no? In my case all of these are useless if I can't allow the viewer to copy/print/csv/etc anything more than the current page results.