1

enter image description here

As you can view on printscreen, drop down is rendered up. Can someone give me a point how to render it down?

code :

final Select2Choice<Country> originCountryDD = new Select2Choice<>("originCountry", new PropertyModel<Country>(this, "originCountry"), new CountryProvider());
 private class CountryProvider extends ChoiceProvider<Country> {

        @Override
        public void query(String codeWithNameFragment, int i, Response<Country> response) {
            if(codeWithNameFragment == null || "".equals(codeWithNameFragment)) {
                response.addAll(countryDao.findAllWithStations());
            } else {
                response.addAll(countryDao.findByFragment(codeWithNameFragment));
            }
        }

        @Override
        public void toJson(Country country, JSONWriter jsonWriter) throws JSONException {
            jsonWriter.key("id").value(country.getId()).key("text").value(country.getNameWithCode());
        }

        @Override
        public Collection<Country> toChoices(Collection<String> collection) {
            Collection<Country> countries = new ArrayList<>();
            List<Country> countryList = countryDao.findAll();

            for(String id : collection){
                for(Country country : countryList) {
                    if(country.getId().equals(Long.valueOf(id))) {
                        countries.add(country);
                    }
                }
            }

            return countries;
        }
    }

Here is my code. I dont know, how to made select2 to render drop down downside. Any help greet.

Dannick Bedard
  • 373
  • 3
  • 14
Petr Kostroun
  • 456
  • 9
  • 27
  • 1
    Hi, I don't know if there's a specific server config for this, but you might find a solution in this other question: https://stackoverflow.com/questions/19983601/prevent-select2-from-flipping-the-dropdown-upward – Andrea Del Bene Jun 10 '20 at 13:27
  • As for today, this feature in on PR: https://github.com/select2/select2/pull/6139 It requires attention from the dev community. – carloswm85 Jun 16 '23 at 12:06

1 Answers1

1

I found some documentation that might help you

There is "forceabove" param.

You should be able to change it to force it below...

Source : https://github.com/select2/select2/issues/3121

Or

You quand try the dropdown placement. select2 is not working properly when it's inside a Bootstrap modal...

Source : https://select2.org/dropdown#dropdown-placement

Community
  • 1
  • 1
Dannick Bedard
  • 373
  • 3
  • 14