Hide page and search controls for empty tables

Hide page and search controls for empty tables

kharr0kharr0 Posts: 4Questions: 0Answers: 0
edited January 2010 in General
Is it possible?

Thanks!
-k

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi kharr0,

    Yes this is possible, but you'll need to add a little custom code to the fnDrawCallback function. What to do is use that callback to see if the settings (fnSettings()) indicate that DataTables is in a state where you want the DataTables controls to be hidden - if it is, then set them to be display:none, otherwise set display:block.

    Regards,
    Allan
  • ShownShown Posts: 4Questions: 0Answers: 0
    edited May 2011
    Is it possible to edit fnDrawCallback from outside .js file? I create dinamically tables within .php file. I searched a bit on documentation but did not find anything useful how to hide a table if it has 0 records. (hiding table will hide only the body, but not the table toolbar). A little simple code would be much appreciated.
    Thanks in advance

    EDIT: seems to have found docs (http://www.datatables.net/usage/callbacks). I will do some tries.
    EDIT#2: with the help of a global var to know the state of initialization of table, the fnDrawCallback did the job. And it was really easy to use!
This discussion has been closed.