I've got an issue with a dependent drop down, I've searched here but cant find anything specific to this problem.
I have a simple dependent drop down:
The 'course' select is a list of course titles in our database that is filtered with a trainingcompanies table - that means we we only show 'live courses' that have companies who are able to carry out that training.
When a course title is selected, the countries table is queried to pull out the countries of all companies who carry out that training. The companies and the countries change with each training course type.
It works perfectly after the initial selections have been made, the problem is on initial page load, the 'country' select doesn't populate. Heres what it looks like:
Both dropdowns trigger on 'updated' and not 'changed' eg dmx-on:updated - I've tried dmx-on:changed and it made no difference. The countries severconnect is a 'no auto load' as we don't know what countries will have records when the page loads.
Maybe try using a Flow (with a short wait of 200ms) to control the load for Countries upon change to the Course? We had something similar and put it down to AC2 being so fast as never had to do this with AC1. All of our No Auto Load Actions are controlled this way these days.
Why do you do a onupdated or any other event for the second dropdown data source?
You just need to add the first dropdown value in the GET param of the second one’s server connect and it will automatically update when a value is selected.
the second dropdown triggers another serverconnect that pulls out company details in the country selected in the second drop down. It all works fine, just not on the initial try on a fresh page or a reloaded page.
But why are you using onupdated event on the first dropdown? All you need is to bind the first select value in the second dropdown data source (its GET param). No need of dynamic events.
Even if an event is required for anything / for some reason you need the onchnaged event, not onpudated.
the first drop down must fire a SC so I can list all countries that have companies who offer the type of training selected, as far as I see it the only way to do this is with an updated or changed event - I have tried both updated/changed and they both have the same result. The countries SC can then populate the second drop down with a list of countries.
Weird, the only way I could get this to work was to create a hidden input under the first select, then use that to run the SC to populate the country select.
I tried all ways to get the first select to do this on its own but it kept failing on the initial page load. It aint pretty but it works ( bit like me really )
Many thanks to all of you for pitching in, your assistance is much appreciated: @famousmag@Cheese@Teodor
When you are using the value of the select as a value for the GET parameter in your server action, the server action will automatically reload when the select value has changed. You don’t need any dynamic events set on the select!
thanks for that, I'm on the latest version: 2.0.10 - it was strange behaviour, I've done this a lot of time before but this time it just wasn't working as expected..
As i mentioned above, you have one unnecessary step in your setup and this is the event loading the server action for the second select data source.
You just need to bind the value of the first select in the second select's server action and it will be automatically loaded!