I made a table for county data. The two columns of importance are the id and name. In my controller in the index function I pass a CountryDto to the page:
countries: CountryDto.fromArray(await Country.all())
In the page, I list it in my props
const props = defineProps<{ countries: CountryDto[], }>()
Copied!
And I pass it to an action component, much like was done with the courses index page in PlotMyCourse
:countries="countries"
Copied!
In the template I have a dialog, and in it I have a form input for a dropdown select to pick a country
<FormInput type="select" label="Country" v-model="form.countryId" :error="form.errors.countryId" required> <SelectItem v-for="country in props.countries" :key="country.id" :value="Number(country.id)"> {{ country.name }} </SelectItem> </FormInput>
Copied!
It works, I can use it to select a country, but both opening the dialog, as well as clicking on the country dropdown take 3-5 seconds to load or close. There are a bit over 200 countries in my table, so I don't know if it is a matter of the amount of data it is having to loop through, or if I am doing something wrong. But having a dropdown with that many options doesn't seem unreasonable. Any ideas on how I can speed this up? I tried converting the country data in the controller to an object with the id and name in it, hoping using that rather than a large DTO would speed it up, but that didn't seem to improve the speed.
Thanks.