Using tabulator, is there a way to allow the user to select what columns are visible? I mean once the table is loaded the user is able to select what columns to be visible. Along with that make this persistent so when the user comes back to this page it only displays the columns he had selected last.
0
votes
1 Answers
0
votes
You have to use the table.hideColumn(column) or table.showColumn(column) functions:
I have a colHidden array of booleans to manage which columns are to be shown. The id of the column (in may case) is the number of the column (They are created dynamically) and I call this function when I want to refresh the table with the values indicated in colHidden array:
const columns = column._column.table.columnManager.columns;
for (var i = 0; i < columns.length; i++) {
var txt="" + columns[i].field + "";
if (colHidden[i]) {
table.showColumn(txt);}
else{
table.hideColumn(txt); } }