Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sr57's avatar
Level 39

Yajra datatable - hide column?

Hi all,

I begin to 'play' with Yajra datatable, it wotks well and has many options / features.

I want the user to be able to hide some columns, does so know if there is an way to do it by config? If not, an other solution already done in js?

Thanks in advance.

0 likes
1 reply
Nakov's avatar
Nakov
Best Answer
Level 73

Yes you can do it dynamically.. so here is the way you should have it initialized and then play with toggling depending on how you want to trigger the show/hide.. I am using checkboxes in such case, so here is an example:

let dataTable = $('#data_table').DataTable({ ..... your options here });
let column = dataTable.column(0); // here is the index of the column, starts with 0
column.visible(false); // this should be either true or false

Please or to participate in this conversation.