Updating single Row via table widget

I'm trying to Update database rows via the table Widget (table_orders). I've set a couple of columns to be editable, and set the "Add-ons Save Action" to run "updateRowTable1" Query that I'm trying to build via GUI mode. This Query filters by "id" key with value corresponding to the currently table selected id ({{ table_orders.selectedRow.id }}) and the tries to update all 4 editable fields (status, comments, etc) with values {{ table_orders.selectedRow.status }}.

When I edit a field in the app and press "Save" the query seems to run fine. There is no log errors, the value in the widget changes, but after 1s it's reverted back to the original value. I assume it's because the Update is actually not happening and them I run the getRows Select query aftwerwards.

Need help understanding why my query is not working. Maybe some suggestion on how to debug this? How can I "see the query code" that the Gui mode outputs to be able to debug?

Retool is Awesome!

I found that I had an "Success Event Handler" on the updateRowTable1 query itself that was getting all values back via getRows (select * from orders).

So, after removing this, the values on the table widget are not changing after "Save. But the top-right corner blue triangles persist (see image) and no change is happening to the database.

.

When I manually run the updateRowTable1 query while having the target row selected I get the JS object of the query but the values are still the original ones, not the one in {{ table_orders.selectedRow.___ }}

Pretty sure it's a query strategy. Because although the table widget, for example, is showing "Partial payed" for the user "Delphinia" (above image) a console.log(table_orders.selectedRow.status) is returning the Original "Cash". But I can find the new data inside the {{ table_orders.changeSetArray }} and {{ table_orders.changeSetObject}}

hello, you are right. only the property `changeSetArray or changeSetObject keep the changed value. The selectedReow.* is refer to the oringial value.

Also If you want to auto clear changeSet you need to set success event handler to your update query.
image

If you modify muti-rows you can use batch updates to update the datas.

Here is my screenshot for your refer.


query11 screenshot

If you want to change the selectedRow only, you can modify the query10

but it will clear changeSet of all Rows.

1 Like

Hi Anson,
This answer was just perfect. Thank you so, so much. I know it's something basic, but you just unlocked my minds and avoided so many hours of work.
Gigantic props to you!

5 posts were split to a new topic: Running an update query on a normalized data model