Hide column initComplete first row colspan="8"
Hide column initComplete first row colspan="8"

in DataTables 2
I am showing and hiding columns on within initComplete.
this.api().columns([6,7]).visible(false).columns([9,11]).visible(true)
However the first row always includes an additional class colspan="8"
If I add .draw() it works okay however this is server side so I get an another call to the server which I'm trying to avoid.
This table includes Editor
Anyone else seen this ?
Thanks
Answers
Datatables doesn't support
colspan
in thetbody
. See the HTML requirements for more details.Are you using the RowGroup extension which, depending on configuration, will insert rows into the
tbody
at the top of each group. Something like this example.Please post your relevant Datatables code so we can get an idea of what you have.
Better is a link to a test case showing the first row with
colspan="8"
?https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I'm not using row group and I do not have colspan anywhere in my js or html code. This is being added to the first row in the table after the initialisation when I show and hide cols. If I redraw .draw() the table during the initComplete I do not get the problem.
Thanks, Here is the code
'''
var timeTaskTable = ltgObj('timeTaskTable').DataTable({
initComplete: function () {
// UPDATING THE SELECT BOX
const timeOff = ltgObj('time.timeOff').val();
let searchDiv = $('#timeTaskTable_wrapper').find('.dt-search')[0];
if (timeOff === 'True') {
$(searchDiv).addClass('d-none');
ltgObj('statusSelect').addClass('d-none');
$('.dt-buttons').addClass('pb-1');
$('.dt-paging').addClass('pt-1');
timeTaskTable.state.clear();
this.api().columns([6,7]).visible(false)//.draw();
'''