I want to add an additional <thead>
that will contain my filters for that column in datatable.
I am able to do that using the following script. (For this to work I should have thead defined in dom)
var tableid = $('#dataTableBuilder');
num_columns = tableid.find('thead > tr:first > th').length;
tableid.find('thead > tr:first').before('<tr id="filter-row"></tr>');
var filterrow = tableid.find('#filter-row');
while (num_columns-- > 0) filterrow.append('<th></th>');
Problem is I do not want to look at DOM to figure out number of columns to add those many <th>
. (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 <table id='xxxxxx'></table>
)
I hope the question is understood, I just need to know how can I get count of number of columns using datatables.
I tried myDataTable.fnSettings().aoColumns.length
but it says "fnSettings is not a function" it looks like it is depricatedin 1.10, is there any alternative to this?