Simply triggering a query on a table in one container from another container

I have a container in my application that has small .png images that represent companies that my customer does business with.

When I click on these images retool changes a variable named "variable1" (weird that is fixed and can't be changed).

When "variable1" is now set to a customer ID, I want a query on the sample data table in another container to run.

I can go to the other container now and set focus on the table and the query will run with the proper results. But I want it to run when I click on the image in a separate container.

I write JavaScript for a living but thought that this was a basic function that I could handle with an event handler on variable change or something.

If I have to use JavaScript and local storage or something, I am happy to, but this seems a bit basic.

That being said, I still can't figure it out.

Thanks for any advice.

Welcome to the forum!

Are you certain that there isn't a event handler somewhere you may have tested but forgot to remove in any of the images?

Additionally, can you add some screenshots?

Thanks Scott,
Let me put together a more detailed (with screenshots) description of my issue. I will include the detail of all the event handlers i have set for each container and table, etc..

This will take an hour or two.

But in the meantime, is the pattern (i'll call it a pattern for now) "trigger-a-query-to-run-and-update-a-table-in-another- container" supported?


I'll get back with more details!

This first container is the customer logos container. When I click on any customer image a variable is being set. variable1 is set to 1 ,2 ,3 etc. to represent the customer ID which is in a table I want to query.

Next is the table in another container that I want to run the query on with just the where clause set to the customer ID or 1,2,3 etc.

So when I click on central oceans logo, variable1 is set to 1.

Then the projects with customer container should fire the query with select 8 from table where id = 1;

It works if i go to the second container and put focus on it. Then the query will fire and the correct record(s) come up. But, I cant ask my customer to go to every screen and set focus. There will be many. I need them all to fire when i pick another logo.

I will be happy to provide detail behind these containers and tables.


Sorry I meant select * from table where id =1;

another oddity, can't edit a post you submitted?

So, basically, when a user clicks on an logo, you want to run a query to get the company data and display that data in a table. I am going to assume that both containers are on the same page? If the logos and the table displaying the data are not on the same screen/page, then you're going to have to pass the id into the url using urlparams and then run the query on the page/screen you are sending your users to after they click on the logo.

What type of database are you using?

Thanks so much for the response. Yes, the two containers are on the same .html page. As of now, just to get a proof of concept and mockup working to show the customer, I am just using the demo database. I have added one table to it to do some other testing. I am just using the id values of 1,2,3,4 and so on to query the sample transactions table.

select * from sample_transactions where id = {{ variable1.value}}

I have this query set on the table in the container and I have an event handler that will run the query when I set focus on the table by clicking on the table. I just don't want to have the customer clicking on the three or four tables that will need to be updated when he chooses a new customer logo.

Thanks again for the guidance.

Why not have the query one when the log is clicked and the table set to {{}}

I don't see a reason to set the focus unless you're saying that the table is below the fold in the initial view when clicking on a logo.... if that is the case, there should be a scroll to event handler as well....

i set focus on the table to fire the query for the reason that I started this thread in the first place. The reason is that I can not fire the query remotely.

I am looking at your comment: Why not have the query run when the logo is clicked and the table set to {{}}.

I think I see what you mean. I have been trying to get the query to run in the remote container. But I can just run the query in the container I'm currently in.

Yes, I was thinking about it all wrong. Wow. I get it. Let me work on this.

Thanks so much. I'll update this thread with results!

1 Like

Thanks! That was so easy after you cleared it up. I thought I had to have queries attached to a table in a container. I see now that I can run the query anywhere and just have the results connected to the table(s) in container(s). This simple idea changes everything for me. Do I mark things as answers or is this done by a moderator?