DataTables 1.10 column count
<p>I want to add an additional <code>&lt;thead&gt;</code> that will contain my filters for that column in datatable.</p>

<p>I am able to do that using the following script. (For this to work I should have thead defined in dom)</p>

<pre class="lang-js prettyprint-override"><code>var tableid = $('#dataTableBuilder');
num_columns = tableid.find('thead &gt; tr:first &gt; th').length;
tableid.find('thead &gt; tr:first').before('&lt;tr id="filter-row"&gt;&lt;/tr&gt;');
var filterrow = tableid.find('#filter-row');

while (num_columns-- &gt; 0) filterrow.append('&lt;th&gt;&lt;/th&gt;');
</code></pre>

<p>Problem is I do not want to look at DOM to figure out number of columns to add those many <code>&lt;th&gt;</code>. (Reason for this is I am using Yajra Datatables HtmlBuilder to generate my table and I do not know number of columns upfront and the table code that this adds is only <code>&lt;table id='xxxxxx'&gt;&lt;/table&gt;</code>)</p>

<p>I hope the question is understood, I just need to know how can I get count of number of columns using datatables.</p>

<p>I tried <code>myDataTable.fnSettings().aoColumns.length</code> but it says "fnSettings is not a function" it looks like it is depricatedin 1.10, is there any alternative to this?</p>