• Resolved vickygr89

    (@vickygr89)


    Hello,

    I have the following shortcode:

    [table id=”6″ filter=”car” cellspacing=”3″ print_name=”1″ use_datatables=”1″ table_head=”1″]

    If the “car” value is not found I would like the table to not show at all, at the moment I can see the table header when that happens.

    Is this possible?

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    I see what you mean, but unfortunately, I don’t have a readily usable solution for this right now. The best idea that I can think of right now would be to use e.g. the tablepress_table_output filter hook, and check if that contains at least two rows.
    For example, add this to the end of your theme’s “functions.php” file:

    apply_filters( 'tablepress_table_output', 'vickygr89_tablepress_hide_empty_filter_table', 10, 3 );
    function vickygr89_tablepress_hide_empty_filter_table( $output, $table, $render_options ) {
      if ( '' !== $render_options['filter'] && false === strpos( $output, 'row-2' ) {
        $output = 'No results found.';
      }
      return $output;
    }

    This will return a message instead of just the header row, for tables that use filtering and where that filtering only returns the header row.

    Regards,
    Tobias

Viewing 1 replies (of 1 total)

The topic ‘Hide Table if filter value is not found’ is closed to new replies.