Is it possible to hide/show table controls dynamically?

Is it possible to hide/show table controls dynamically?

dogcatgoatdogcatgoat Posts: 38Questions: 0Answers: 0
edited March 2011 in General
Hi,
The search, show, page forward/back, and other controls on DataTables clutter working with small tables. I have several tables that usually get populated in my app which usually have between 0-20 entries. Is it possible to hide the controls for tables that only have say 10 or less entries? Is there a way to access the sDom variable dynamically?
Thank you.

Replies

  • dogcatgoatdogcatgoat Posts: 38Questions: 0Answers: 0
    Would using JQuery to manually delete/add the controls back be the best solution?
    Thanks,
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    You can't modify the feature enablement dynamically in DataTables (well you can - but it's not designed for that) - however what you can do to achieve the effect of it is simply hide the elements when you don't want them. For example $('div.dataTable_filter').css('display','none'); will hide the filtering input.

    Allan
  • dogcatgoatdogcatgoat Posts: 38Questions: 0Answers: 0
    Dear Allan,
    Thank you very much for your response.
    I can see that there are other also elements such as:

    dataTables_length
    dataTables.info
    dataTables.paginate

    If I have multiple data tables, though, I wasn't sure how I can selectively turn on/off the display for each of them. Right now the div.XXX.css.('display','none') acts globally across all my tables. Ideally I would like to display tables with lengths such as 2, 41, 13, 0 on the same page and I would like the flexibility to hide the controls depending on the table size.
    Thanks again :).
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    The are a number of ways of doing that - do the tables have IDs? In which case you can do something like $('#ID_filter').css('display','none'); etc. Another option is to use oTable.fnSettings().nTableWrapper - which will give you the node for the container element for any given DataTables instance.

    Allan
  • dogcatgoatdogcatgoat Posts: 38Questions: 0Answers: 0
    Dear Allan,
    Thank you for your advice-- both techniques you suggested work!

    kind regards
This discussion has been closed.