Category: Appsmith Support
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Dropdownlist defaultvalue showed up in modal but not triggering the optionchange event

Issue

I have a problem where the option change event in my dropdownlist in the modal doesn't trigger another query until I manually change the option. I tried searching for a solution in the community but couldn't find one. I'm wondering if there's a workaround for my case.

Resolution

The issue was that the optionchange event in a dropdownlist within a modal was not triggering when the default value was set programmatically. The solution was to either run the query right after setting the default value or trigger it from where the modal is being opened.

To implement this solution, code can be added to the table rowselected event. When the showModal function is called to open the modal, a chain of queries can be run using the .then() method. The code would look something like this:

{{showModal(‘modal_upd_xxx’)
.then(()=> query_upd_1.run())
.then(()=> query_upd_2.run())
.then(()=> query_upd_3.run())
}}

This will ensure that the queries are executed when the modal is opened, even if the default value in the dropdownlist was set programmatically.