Title: Hide Published Table
Last modified: September 18, 2020

---

# Hide Published Table

 *  [samonpress](https://wordpress.org/support/users/samonpress/)
 * (@samonpress)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/hide-published-table/)
 * I was wondering if it’s possible to completely hide a table (using short-code
   from data publisher) when there’s no data available in it?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * (@peterschulznl)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/hide-published-table/#post-13426908)
 * Hi [@samonpress](https://wordpress.org/support/users/samonpress/),
 * I think you can do that. You can write a JavaScript function to handle this action
   based on your search results. The table is shown inside a div. You can hide the
   div or the table in your css on startup. You then have to check if the table 
   contains any data. If so, you can show the table.
 * If you do it the other way round (show the table on startup and hide if no data
   was found) the user will see an empty table before it is hidden.
 * I’m just wondering where to put your JavaScript function. You can try to execute
   it when the page is loaded, but I’m afraid that to early. At that moment you 
   might always find an empty table. Maybe add a dealy?
 * @anyoneelse an idea…?
 * Please let me know how you continue…
 * Best regards,
    Peter
 *  Thread Starter [samonpress](https://wordpress.org/support/users/samonpress/)
 * (@samonpress)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/hide-published-table/#post-13427346)
 * Thank you for the response Peter!
 * I thought of solving it by checking if the user is logged in, if yes then show
   table else hide. (Because if Yes – then there must be some data).
 * I was trying to use Table Option (advance) within Data Publisher. From another
   topic I learned that I’ve to disable JSON validation and toggled it to textarea
   without JSON validation to avoid the error message.
 * For the beginning I am only trying to hide the table in advance option but nothing
   seems to be happening. Here’s the code and I’m sure I might be doing something
   wrong. Can you please help.
 *     ```
       $(document).ready(function() {
            $("#tdwholesome21_wrapper).hide();
       });
       ```
   
    -  This reply was modified 5 years, 8 months ago by [samonpress](https://wordpress.org/support/users/samonpress/).
 *  Plugin Author [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * (@peterschulznl)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/hide-published-table/#post-13430174)
 * Hi [@samonpress](https://wordpress.org/support/users/samonpress/),
 * I’ve been experimenting a little and found a solution. Please enter this JSON
   in your table options advanced column:
 * {
    “initComplete”: “function( settings, json ) { if (json.recordsTotal==0) { 
   jQuery(‘#tdwholesome21_wrapper’).hide(); } }” }
 * The JS function will be executed after your initial query. When no rows are found(
   json.recordsTotal==0) the wrapper div is hidden. I would advise to hide the wrapper
   div (set style display:none) and make it visible when rows are found. Otherwise
   the user will first see your table appear and then disappear.
 * Allow me to add few notes:
    – The content of the table options advanced column
   must be valid JSON – You cannot enter JS code in the table options advanced column
   directly – You can only use JS code in the table options advanced column for 
   events
 * Here is some background information:
    [https://datatables.net/reference/option/](https://datatables.net/reference/option/)
   [https://datatables.net/reference/option/initComplete](https://datatables.net/reference/option/initComplete)
 * Please let me know if this solves your problem!
 * Best regards,
    Peter
 *  Thread Starter [samonpress](https://wordpress.org/support/users/samonpress/)
 * (@samonpress)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/hide-published-table/#post-13431193)
 * Hi Peter!
 * I tried with this code in Table Options advance column. It gives an error as 
   follows:
 * Parse Error on Line 1:
    {“initComplete”: _^ Expecting ‘STRING’, ‘}’, got ‘undefined’
 *  Plugin Author [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * (@peterschulznl)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/hide-published-table/#post-13432961)
 * Sorry [@samonpress](https://wordpress.org/support/users/samonpress/)! The quotes
   are changed when you post a message. I had to put the JSON in a code tag. Please
   try this:
 *     ```
       {
       	"initComplete": "function( settings, json ) { if (json.recordsTotal==0) { jQuery('#tdwholesome21_wrapper').hide(); } }"
       }
       ```
   
 * Sorry,
    Peter

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Hide Published Table’ is closed to new replies.

 * ![](https://ps.w.org/wp-data-access/assets/icon-256x256.png?rev=3299063)
 * [WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards](https://wordpress.org/plugins/wp-data-access/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-data-access/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-data-access/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-data-access/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-data-access/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/hide-published-table/#post-13432961)
 * Status: not resolved