colvisGroup throwing unknown button type error

colvisGroup throwing unknown button type error

cliff_knasinskicliff_knasinski Posts: 2Questions: 1Answers: 0

I am getting an error when trying to utilize the column visibility extension with colvisGroup. "Cannot extend unknown button type: colvisGroup.

It errors out at jquery-3.3.1.js:3827

In the debug window I can see it is loading the buttons/1.5.2 scripts, as well as jquery.dataTables.min.js and datatables.min.js.

I am referencing the below in my _Layout.chtml file.

Any help would be appreciated.


<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.print.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.colVis.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.10.18/b-1.5.2/b-html5-1.5.2/b-print-1.5.2/r-2.2.2/sc-1.5.0/sl-1.2.6/datatables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.bootstrap.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.10.18/b-1.5.2/b-html5-1.5.2/b-print-1.5.2/r-2.2.2/sc-1.5.0/sl-1.2.6/datatables.min.css" />

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.5.2/css/buttons.dataTables.min.css" />

The script for the table is:

$(document).ready(function () {
$('#CProjects').DataTable({
language: { search: "Search" },
dom: 'Bfrtip',
buttons: [
{
extend: 'colvisGroup',
text: 'Office info',
show: [1, 2],
hide: [3]
},
{
extend: 'colvisGroup',
text: 'Show all',
show: ':hidden'
}
]
});
});

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,083Questions: 26Answers: 4,908
    Answer ✓

    Looks like you are loading Buttons twice negating the buttons.colVis.js include.

    If you click the link for your concatenated Datatables JS you will see what is included.
    * Included libraries: * JSZip 2.5.0, DataTables 1.10.18, Buttons 1.5.2, HTML5 export 1.5.2, Print view 1.5.2, Responsive 2.2.2, Scroller 1.5.0, Select 1.2.6

    You are loading buttons individually then colvis.js then buttons again with the concatenated file. You should only load the JS once.

    Kevin

  • cliff_knasinskicliff_knasinski Posts: 2Questions: 1Answers: 0

    I had added the references to buttons because it was not loading the buttons extensions before. I deleted all references and recopied the minified links. It worked.

    Thanks.

This discussion has been closed.