Don't show data from a query unless selected?

Hello,

Back with another question for something I’ve been trying to figure out for the last few days. I have query setup and checkboxes to filter that data. It’s setup exactly the way shown here: https://docs.wappler.io/t/filtering-database-query-with-multiple-checkboxes/4053

And while this works, I want to exclude the data from the intial shown data unless selected to show by ticking the checkbox. How can I achieve this?

I think I can answer this, at least this is one way. You need to check No Auto Load on your server connect:
image

Then, under Dynamic Events for the checkbox group, use an event to load the data. Might be Select or Changed under Input or maybe Value Changed under Data. Once you have the event included, go into the dynamic data picker and select your server action and select the “load” option:
image

1 Like

Thanks, but this would result in no data loading, where as I want only those that fall under the array not to load intially unless ticked instead of all the data.

Sorry, I guess I misunderstood your question. I thought you wanted no data initially.

It sounds like you have more data in your table then what you have checkboxes for. Is that correct? If so, you could define the query to return the filtered values OR anything else.

Something like: WHERE CategoryId = :CategoryId OR (CategoryId <> 1 OR CategoryId <> 2 OR CategoryId <> 3)

Assuming your checkboxes are Categories 1 to 3

Correct. So essentially right now an entry in the database can have several statues. All of the entries are fetched, but I want certain statues to only display if the checkbox is ticked. Using the guide previously linked in works to the extent if you click the checkboxes only the relevant entries with the statues are shown, but I want these to be excluded from the default data if that makes sense.

For example, I have the following statues from each entry:
Status 1
Status 2
Status 3 (Only shown when the Status 3 checkbox is selected)

Only Status 1 and 2 should show by default unless you click the checkbox for status 3.

The query conditions currently look like this so that the checkboxes work. I’m just not exactly sure what I need to modify here so anything in this array is not shown by default.

Do all 3 of these have a check box or only status 3?

2 and 3 have a checkbox, 1 does not.

is 1 always shown or can this also be toggled?

One is only shown on the initial load, once you toggle the checkboxes for the others this is no longer shown.

What I want to achieve is that two and three do not show on this initial load, only when selected.

Then you could add 1 to the array or do something like add a extra condition to your query making sure its not in the same group as you’ve shown here with issues_status been equal 1 (you would need to check the array has no values here)

I’m not sure I understand what you are trying to explain here.

I’ve tried using conditions to not display anything in the array, but this then prevents the checkboxes from working.

I think we are thinking differently here maybe this is more what you are trying
you have 3 filters 1 2 3
you want
1 to show by default?
then 2 and 3 to show if selected
does 1 still show when 2 or 3 is selected?

Here is a gif. I have removed the additional checkboxes to simplify the explanation.

You can see that in the default state, where the checkbox is not clicked all results show. But when clicking the checkbox, only the items with the status “Closed” show.

I want it so that items with the status “Closed” do NOT show when the checkbox is unticked, only when it’s ticked should they show. The button has been setup using the method here: https://docs.wappler.io/t/filtering-database-query-with-multiple-checkboxes/4053

This is one way this might work I haven’t tested this yet thought

new is my array name the top one is when a box is checked as the array has values
the Bottom should only trigger when the array has nothing in so before any boxes are checked (here you would add and filters for the initial load)

1 Like

Aha, this was it, thank you! I had been stuck on this for days. I had tried so many different conditions but what I was missing was the “== null” on the condition.

Thank you very much!

hello, im having a similar problem, i have a simple databse query of first _name the problem is i dont want the details to be shown initially until filtered through a text input,

ive set up the filter and text input it works, but when theres no input the first name on the database shows up, i only want the details to show when i start filtering them, how can it be done?

Can you post a screenshot o some code so we can help you?

thanks i resolved it, i hid all query results if when the filter has no value. quick issue i set a validitor to check if email already exists when i click to submit a hidden form it works and i get message from there the button no longer returns the message but nothing as expected is being inserted…i want to validate and display error message every time button clicked

I think you should better create a new topic asking that, we’ll glad to help you