[OutSystems Data Grid] SAVE OnCellValueChange not working
Reactive icon
Forge component by Gonçalo Martins
Application Type

I have the DataGrid working when the user clicks a SAVE button. However, I would like it to auto-save as well. 
Ideally, it would save when the OnCellValueChange event fires - but - that does not work. I am guessing it is an event timing issue.

Then I thought maybe IF there is a cell that has changed, set a logical var and have some kind of background thread wake up and auto-save every so often.

Ideas? Is it possible to SAVE when the OnCellValueChange - or - maybe another way to not need a SAVE button?

Hello @Bruce Buttles

Could you please share a sample oml (business agnostic) with the way you're trying to implement this and, indicate exactly what you want to achieve and for which use cases?

Also, have you tried an approach similar to the one mentioned here to enforce the code to run async (by using a setTimeout) in order to be able to get the changed line data?


The OML is too large, Forum wont let me upload. I am using the RequestList page in the OutTracker app (from Forge).

I took the approach that @Nghia Hoang suggested and it worked BUT have another challenge to solve.
Solution thus far:

1) AutoSave action has JS with setInterval that calls SaveChanges every 15 seconds ONLY if there are changes to save. Note: I kept the Save button but it disables when there are NO changes to save. So, this works great .... but ...

2) BUT - at the end of SaveChanges, I have to refresh the data source so that the other page elements will get the new data. However, this causes the DataGrid to refresh which interupts the user as they make more changes. Imagine, user makes changes and clicks tab, then user starts making more changes - but - the 15 second timer is up, edits are saved - BUT - the DataGrid UX refreshes and the edit that the user was in the middle of making are lost.
So, now we need a dependable way to save and not have the DataGrid UI refresh but still have the datasource get refreshed for the non-grid table on the FRONT of the card.

See screenshots.

Hi Bruce,
I think to put the logic of saving data in the onchange event of the cell will have a down side is that if user interacting too fast, the server will be spam with too many request. And to solve this we need to implementing some debounce mechanism. It'll cost some time to develop that. 

To me, I prefer a simple solution is to have Save action triggered after some time (for example: every 7 seconds). To achieve this, we just need some JS to call setInterval, or just simple to use this Component: Trigger Action to periodically trigger the click on the Save button.

One notice is the for the Sceen Action that call the ServerAction to save the changes to the DB, we can put some check to: only call the Server Action if there's "dirty" cell(s). And if you want to remove the visual of the Save button on UI, just add "hidden" to its Style Class: 

@Nghia Hoang please see my reply above to Goncalo. You will see that you and I were thinking the same thing! :) But, need help to make the experience polished. See above and thank you.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.