Error with JQuery DataTables and ColVis plugin "Cannot read property 'sWidth' of undefined"

datatables, javascript, jquery

Solution

I had this error when the number of columns in

<thead></thead>

was different from the number of columns in

$('#ls-table').DataTable($.extend({}, window.coonDataTableOptions, {
    columns: [
         <here>
    ]
 }));

Problem

Using the jquery.datatables plugin with the ColVis addon, I recieve this error when I remove a column: "Cannot read property 'sWidth' of undefined". I haven't been able to find a solution to this error online. I'm not sure what's causing the error, although I do have a fix that I would like to post for the benefit of other's who run into this issue. I'm using jquery.datatables 1.9.4 from http://datatables.net/.

Original source