EditableTable - how to manually invoke Add via Javascript

I have a requirement that whenever anyone were to add a Country, i want to force the user to add the state as well. For example, when the user adds a country "Malaysia", I want them to add at least 1 state such as "Kuala Lumpur"

Currently I am using the EditableTable widget for user to add state to each country they are adding to the page.

If they did not add any state, i want to invoke the "+" to add a blank row and force them to key in.

Which function (Outsystems or Javascript) should i use?


Instead of trying to mimic user input on the client side, you should try adding an empty record to the List that feeds the EditableTable. I'm not sure if there's a way to directly interact with an Editable Table like that, and even if there was, it's risky because it could be prone to break if the underlying implementation changes in an Outsystems update.

I tried to add an empty row but it does not show up in the table. 

I did it by a local variable of type CountryState where i set the CountryState.Id = 0, CountryState.Name = "", CountryState.CountryId = 0.

Nothing happened at all.

Did you AJAX refresh after adding your element to the List?

Could you share your espace?

Dear Afonso

Yes after I did a listappend, i followed by a ajax refresh of the editabletable (i also tried to ajax refresh the Container). Nothing seem to happen.

I am sorry, my network is isolated, so i cant upload the oml or espace too.

Oh sorry, i forgot to mention i am using Outsystems 10 on my client pc.

Did you ListAppend into the List that you mapped to the EditableTable, or did you point to the EditableTable.List?

Without seeing your espace it's going to be trickier to diagnose, but we'll try to take it step by step.

yes, I appended to the EditableTable.List, not to the list mapped

PS: It is about 12 midnight here, so I might not be able to reply until 8 hours later. 

Sorry it took me so long to get back to this.

Can you tell me if this espace has the behaviour you're looking for? If the first attribute isn't filled out, whatever you tried inserting is lost and a blank line is added.

Dear Afonso

Sorry it also took me longer than expected to get back as the IDE was not available and I cannot test your OML. Thank you so much for taking your time to assist me.

Your solution worked but the client has a different expectation. Let me elaborate with the following field layout.

The top part contains input fields and the bottom part contains the editable table.

Input 1 - Combo Box: Select Malaysia

Input 2 - Text: Describe population and weather.

Editable Table (to add all the states)

[field 1: state name] [field 2: population count]

[Save button]

When the user clicks on Save, the page has to check that there is nothing in the list, hence it will add a blank row with the red border highlighting the two blank field inside of the editable table to inform the user that they need to add at least 1 state.