Datatable Hide Empty Columns

Hi, I may just be missing something but is there a straight forward way for hiding empty columns in a datatable? My column may or may not have cell data, I just want to hide it if all the rows have no data for that column. I’m thinking maybe using the template property with a function? Thanks

DataTable can’t hide empty columns automatically.

You can use onready handler that will iterate through all rows and will call hideColumn if all values for some column is empty.

Ok thanks, I will try that method

Hello maksim.

This thread is quite old but in the last nearly 9 years is there a solution to set empty columns to hidden=true if they are empty?

with kindly regards
Michael

Good day @Michael,

At the moment, the solution described above is relevant. There is also an option to hide (by using column’s attribute hidden) unused columns before data loading into the table, using the method onBeforeLoad().

Yes It’s a solution. I set a marker for if field has a value. And if marker is set to true, I use table.hideColumn(‘column’);

Maybe I’ll find a better one.

Thank you NatashaS

Michael

1 Like