I have a form which associates a database record with a particular county. I have managed to fill the select list with countries from the database. My problem is how do I select the default value for the select list for a current record. I have tried the following but this does not seem to work
The country_id is a valid id from the countries list but I want to display the corresponding country_name.
Can anyone advise how to set the current value for the list as using the default value as shown is not working.
Default value should exist in the values list. Can you share more about what getFBLeague.data.Country_id, getCountries.data.id and getCountries.data.Country_Name look like at runtime?
@mkhalford You might want to try {{getFBLeague.data[0].Country_id}}, assuming that index 0 is the value you want to be your default value. Country_id would then show the value of the property Country_id
getFBLeague returns a result of parameterized SQL query. Will only ever return one row.
select * from FB_League WHERE id={{state2.value}}
Query returns correct data. If put results into text or numeric input components everything is correct. Its just the setting of the default value for the select component where the issue is.
I have even tried saving the Country ID to a state value before loading screen but still am unable to get the select component to show any value.
This is how its working for me. Getting a list of branches for a MySQL db.
The default value has to be the same as the values, in my case it is a string of two characters (NL)
@mkhalford here's a simple demonstration app for Select's default value. One issue you may be running into is that the default value needs to be a string, even if the values are numbers.
After further investigation you are correct. The key values in question are integers not strings.
Might have to look at a different solution as majority of values that we will need to use for lookups etc. are numbers.
With my limited java skills I tried stringing value using {{ lstFBLeagues.data[0].Country_id.toString() }} but still no luck. If I change default value to a hard coded value like {{"1"}} it works fine.
League_Name is no good. I'm trying to set the default value for the country associated with the league.
I have a list of countries (id (int), country_name (nvarchar)) and the selected country id is held in the league record table (id (int), league_name (nvarchar), country_id (int)).
All I need to do is when displaying a league record set the select component to be the corresponding country_name based on the country_id of the league.
Stringing the country_id would be the answer but all attempts to do this are failing. As stated earlier in conversation forcing a string example {{"2"}} works.
@mkhalford do you mind starting an email thread with me at braden AT retool dot com? I can probably figure out what's going on in a live debugging call.