I am new to using Retool so apologies if this is a naïve question. I am trying to figure out if there is a way to reference the component that triggered the query inside query's code. Something like this:
{{ self.triggeredBy.value }}
// Here triggeredBy would be the component that triggered the query
My use case is to create a table with inline editing experience, similar to that of a spread sheet. Whenever a table cell updates I want to fire a query with the data of the updated cell so I need a reference to the cell that fired the query.
From the docs, I found out that there is a triggeredById variable available but it doesn't seems to be available in a database (Postgres) query.
Furthermore, I learned from the forums that the only solution that works with triggeredById is to create a dictionary/lookup of components ahead of time. This is not possible for my case because I am using a table populated by a database query so I can't know in advance what components will be there.
Is there a way to reference the component that triggered the query inside query's code? (in my case its a Postgres database query)
Can you provide a bit more context into what you're trying to do? Based on what you said, you're displaying some data (from a database table?) and you want to update a table when the cell changes. Are you just updating the original data to the new data, in the same table? Or are you trying to track some kind of meta-data?
If it's the former, you can make a whole table editable and configure how it writes back to the database by configuring this option:
You can also make individual columns editable if you want to limit the edits. You configure a save handler, but Retool can keep track of all of your changes and feed them into the handler.
My goal was to create an user experience with Retool table which is similar to that of a spreadsheet where you can edit any cell right from the table.
I am displaying the data in a Retool table component that is backed by a Postgres table. Whenever the user edits any cell in the Retool table I want to update the corresponding column in the Postgres table.
The solution I ended up with was making the columns the editable and using the changesetArray property of the Retool table to perform a batch update on the Postgres table.