【问题标题】:Select2 drop down is shown upSelect2 下拉菜单显示
【发布时间】:2020-06-10 12:57:49
【问题描述】:

正如您在打印屏幕上看到的那样,下拉菜单被渲染了。谁能告诉我如何渲染它?

代码:

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;
        }
    }

这是我的代码。我不知道,如何使 select2 呈现下降趋势。任何帮助打招呼。

【问题讨论】:

标签: jquery-select2 wicket


【解决方案1】:

我找到了一些可能对您有所帮助的文档

有“forceabove”参数。

您应该可以将其更改为强制低于...

来源:https://github.com/select2/select2/issues/3121

或者

您可以尝试下拉位置。 select2Bootstrap 模式内时无法正常工作...

来源:https://select2.org/dropdown#dropdown-placement

【讨论】:

  • 但这里是javascript版本。我看到css中有class force-above,但没有class force-down。你知道检票口版本吗?
  • 你试过用谷歌浏览器玩吗?也许这是问题的边缘......
  • 是的,我在 chrome 中尝试过,它似乎有效。也许只是 IE 问题。
  • 是的...不再支持 Internet Explorer...如果您想继续使用 Microsoft,请尝试 microsoft edge ;)
猜你喜欢
  • 2018-03-28
  • 2023-03-20
  • 2021-10-14
  • 1970-01-01
  • 1970-01-01
  • 2018-08-18
  • 2012-05-27
  • 1970-01-01
  • 2015-11-30
相关资源
最近更新 更多