Best way to display/refresh ONLY Last Updated Row in Table Data, without refreshing all Table Rows

Hello,
I could use some help with the following ;

I've created a Table with about 200 rows of Table Data from the connected database.
It is possible to select 1 row and to update that selected row.
After updating the Row, the Table Data refreshes, so the updates become visible in the refreshed table.

Issue; it takes several seconds to refresh ALL rows. Therefor I only want to refresh the last updated row.
Can someone brainstorm with me on how to achieve this? Perhaps a temporary state..

Currently Table Data is set to; insertDataBre.data
The second query here below is the query to update a selected row.
Schermafbeelding 2023-11-22 130300
Schermafbeelding 2023-11-22 130331

I've had similar use case - my solution was to store the query data locally in a temporary variable and when they make a change I'd update that row in the variable and not re-run the Get query.

I found that having the table point to a variable for it's datasource that's initially populated by a query gave me more control over the refreshing.

To the user it looks like their changes are instantly updated, then in the background I'd run the update commands.

If it's successful I do nothing (except add the primary key if it was an insert) and I'd disable editing on the row while a save was in progress for it.

1 Like

Thanks a lot for your prompt (and useful reply). Could you perhaps share some code that I could try to realize this?

I am not sure if this would work for my use case. though... to give some background info;

I have a table with reservationnumbers, and a column 'arrived'.
By default all rows of arrived have value '0', because initially 0 persons of the reservation group arrived.
The end user will count how many persons of the reservationgroup arrived.
There is a numbersinputfield where they can set a number. When they click 'arrived' the selected row will be updated and in the background the number set in the inputfield will be added to the current value of the arrive column.

For example;
2 persons of a group of 10 arrived. They are the first persons that arrived from that group.
Number inputfield is set to 2 by the end-user.
Background; selectedRow.data.arrived was 0, add 2, new value is 2

Then another person of that group arrives. value was 2, add 1, new value is 3.

The changes of the updated row become only visible in the table when the table data is refreshed, because the end-user doesn't make the update directly into the table. They change the data by using a numbersinputfield and 'arrived' button, outside of the table.

Oh I see, ok - here's a quick example of what I think you're wanting to achieve.

A table that uses a variable as it's data source, an external component that allows editing of the selected row in the table, a save function that runs in the background

The table is up to date with what the user has changed without needing to reload the query and the save to the database is done in the background. You would probably want a failure handler too.
This simple example pretends to "save" and waits a few seconds to simulate the save process.
forum.json (38.2 KB)

2 Likes

Great alternative. Even though this still does not 'resfresh' only one table row,
it does give the end-user the illusion that the changes were updated instantly.
I'll try to implement this in my app. Thanks

Sure, it's a bit of a cheat in that way but unless the save function does something more than save the changes you're passing it (like generating a primary key or similar) then this model should work

I have the same issue. I really don't want to call my headless CMS API every time someone updates one record. I know it runs the risk of a user not seeing the most updated data, but it just feels excessive.