column visibility not working
column visibility not working
hnorman138
Posts: 12Questions: 5Answers: 0
I have 2 perfectly working datatables, but when trying to get column visibility (option to drop/hide certain columns) the option doesn't show up at all, it just shows my other dropdown options. In addition to the code below, I've also added all necessary CSS files.
<script type="text/javascript" src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.3.1/js/buttons.colVis.min.js"></script>
<script type="text/javascript">
(function($) {
$(document).ready(function() {
$('#mytable').DataTable({
dom: 'Blfrtip',
buttons: [
'colvis'
]
});
$('#mytableSurvey').DataTable({
dom: 'Blfrtip',
buttons: [
'colvis'
]
});
$('.dataTable').wrap('<div class="dataTables_scroll" />');
// select change event
//$(document).on('change' , '#select-tables', function(){
// var table = $(this).val();
//$('#' + table +'_wrapper').show();
//$('[id$="_wrapper"]').not('#' + table +'_wrapper').hide();
//}).change();
$(document).on('change' , '#select-tables', function(){
var table = $(this).val();
$('#' + table +'_wrapper').show();
$('[id$="_wrapper"]').not('#' + table +'_wrapper').hide();
});
$("#select-tables").trigger("change");
});
}(jQuery));
This discussion has been closed.
Answers
You need to include the Buttons core library as well:
The download builder is available to make sure that all dependencies are satisfied.
Allan
Thank you for the answer, I have actually included that now as well as using the download builder but it's not working. However, the code with all included libraries/CSS works on my test site, just not on this wordpress site. I'm wondering if something's conflicting.
Can you provide a link to your test site so we can take a look please?
Allan
This conversation seems to be happening in two different places.
I'm closing this discussion as a duplicate.
Allan