jquery-select2wicket

Select2 drop down is shown up


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.


Solution

  • 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