Change column defs properties, such as width, dynamically after datatable has already been created?

Change column defs properties, such as width, dynamically after datatable has already been created?

clueLessNewbclueLessNewb Posts: 1Questions: 1Answers: 0
edited July 2020 in Free community support

I want to be able to switch my table to different layout of columns

Different layout will have different columns visible and different widths.

in table initiation i have set

"autoWidth": false,
and provided it with initial defintion of the default layout of columns

Afterward

I see that I can get a reference to a column as so and change its visibility

var currentColumn = dt.column(strDesiredColumnName+ ":name");
currentColumn .visible(boolDesiredColumnVisibility);

How do I do the same for the column width?
Or if that fails, what's the best way to alter the column definition?

Answers

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin

    If there is an API method for it, then you can change it - e.g. the visibility as you have found. But most do not have such an option and thus cannot be changed after initialisation. You’d need to destroy the existing table and then create a new one with your new preferred options..

    Allan

This discussion has been closed.