How do I pass options to ColVis when initialised with new?
How do I pass options to ColVis when initialised with new?
Hi, I'm new around here, and just started integrating ColVis into our site last night.
Although I'm not blocked by this, I'd like to know for future reference. I'm using jQueryUI styling, so I'm following the recommendation to initialise ColVis seperately.
I have:
var table = jQuery('#rhac-re-results-table').DataTable(
{
"columnDefs": [
{ "orderable": false, "targets": 8 }
],
ColVis: {
exclude: [8]
}
}
);
var colvis = new jQuery.fn.dataTable.ColVis( table );
jQuery('#rhac-re-results-table_length').css('width', 'auto');
jQuery('#rhac-re-results-table_filter').css('width', 'auto');
jQuery( colvis.button() ).insertAfter('#rhac-re-results-table_filter').css({ 'float': 'right', 'margin-right': '1em' });
As you can see I've tried adding a ColVis attribute to the DataTable argument object, but it doesn't seem to get passed to ColVis, and there doesn't seem to be an options() or similar method that I can call.
This question has an accepted answers - jump to answer
Answers
I had the same problem. I'm still on legacy versionDatatables 1.9.4 ColVis 1.0.8. But this works for me...
Second parameter for the
ColVis
constructor. It takes exactly the same options as thecolVis
option in DataTables.Allan
perfect, thanks to you both.