DataTables logo DataTables

via Ad Packs
Hide empty columns
  • viegaviega
    Posts: 2
    Hi there,

    I am pretty new to Datatables, so sorry in advance if this has been asked already - but the search function does not return a result I can work with.

    I am generating a table using a server side script. The script returns a pretty big table. Only some of the columns are filled and they differ from result to result. Is there a way to hide empty columns (while the header is filled) after generating the table?

    Dennis
  • allanallan
    Posts: 15,851
    The simple answer is no - there isn't way build in way of doing this. Having said that, there is no reason why the API can't be used to do this - all you could need to do is know if a column is empty or not (http://datatables.net/plug-ins/api#fnFilterOnReturn might help with that) and set the column visibility to hidden or not: http://datatables.net/api#fnSetColumnVis

    Allan
  • viegaviega
    Posts: 2
    Thanks for the hint!
    I now just check if a column is empty using the serverside script and hid them with fnSetColumnVis. That works for me :-)

    Dennis
  • okeletokelet
    Posts: 1
    Could you paste an example how have you done this? Looping over all columns and then hide those empty...

    Regards.
  • sergeserge
    Posts: 1
    Allan, I'm a bit confused, your link points to fnFilterOnReturn (although clicking it actually takes you to fnGetHiddenNodes), what does dealing with the return key have to do with seeing which columns have no data?
This discussion has been closed.
← All Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Support

Get useful and friendly help straight from the source.

In this Discussion