column hiding and widths
column hiding and widths
hi there,
i had written my own version of the old ColVis plugin a few months ago (tragically it was about 2w before you came out with the latest release and a more robust, efficient version of it doh!). I do something like this:
if (toggleColsOn.length > 0) dtApi.columns(toggleColsOn).visible(1, true); redraw = true;
if (toggleColsOff.length > 0) dtApi.columns(toggleColsOff).visible(0, true); redraw = true;
if (redraw) dtApi.columns.adjust().draw(false);
I track what the user wants to add/remove from their view and then upon clicking an update function build out the specs to pass on to the columns(myArray).visible()
method.
The issue is that my table shrinks when I do this rather than staying full within the modal it's operating in, the original bounds of the <div>
it is nested in. What would be the best way to maintain a full width here?
Best,
Answers
Try setting https://datatables.net/reference/option/autoWidth to false.
Actually, simply adding
width="100%"
as an attribute to your HTMLtable
is the way to do this.I've been considering removing the ability to disable
autoWidth
. I probably won't, but it is an option for the next major version.Allan