Skip to content

Easy way to hide a table or list if a $param is not set? #185

Answered by lorefnon
shah asked this question in Q&A
Discussion options

You must be logged in to vote

We can do conditional selects for the detail table:

select 
    'table' as component
where coalesce($drill_param, '') <> '';
select 
    name,
    dob
from users
where coalesce($drill_param, '') <> '' and users.cohort = $drill_param;

This approach requires putting the condition in both places - the component selection as well as data selection.

Alternative, is to use a card with embed:

select 
    'card' as component,
    1      as columns;
select 
    'Users' as title,
    '/users_table.sql?_sqlpage_embed' as embed
where coalesce($drill_param, '') <> '';

Where the users_table.sql has the SQL for rendering the users table. It will be fetched and injected into the page after load if the $d…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@shah
Comment options

Answer selected by shah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants