.fixedColumns().relayout() not working
.fixedColumns().relayout() not working
My table initialisation looks like this:
var table = $(tableSelector).DataTable({
order: [],
"paging": false,
"scrollX": 900,
"scrollY": 550,
scrollCollapse: true,
buttons: true,
fixedColumns: {
leftColumns: 1
}
});
It uses html-sourced data. When html data changes, I reitialize it with this code. Everything works fine except one thing: if the table appears to be smaller than screen in width, i see duplicated left column and other columns scattered on the width od the screen like this:
I'm using the example code from here (https://datatables.net/reference/api/fixedColumns().relayout()):
$.fn.dataTable
.tables( { visible: true, api: true } )
.columns.adjust()
.fixedColumns().relayout();
But it doesn't work. And also WebStorm tells methods adjust() and relayout() are unresolved.
I don't know, where is my mistake. Please, help:)
Answers
I left out the headers of the table, becase they represent db fields and my compony wouldn't be happy))
I found a solution: just set "scrollY" to 0. Is there some other way to do it?
Facing same issue
1. when the data is small table doesn't resize (fixed column width)
tried api listed but din't work.
$('#dataTable-' + tableID).html(_tableTemplate);
$('#myDataTable-' + tableID).DataTable({
scrollY: "300px",
scrollX: true,
scrollCollapse: true,
paging: false,
fixedColumns: { leftColumns: cols },
ordering: false
}).fixedColumns().relayout();
Current output : https://imgur.com/MUdQsrZ
Expected output : https://imgur.com/a/ctbjR
Hey I gave a delay ..It works fine for me...
Tried reaching you out for same but couldn't find you ..Search me as ashish9342 in google