显示 Select2 下拉菜单
Select2 drop down is shown up
如您在打印屏幕上所见,下拉菜单已向上呈现。谁能告诉我如何渲染它?
代码:
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 呈现下降的缺点。任何帮助问候。
我找到了一些可能对您有帮助的文档
有“forceabove”参数。
您应该可以将其更改为强制低于...
来源:https://github.com/select2/select2/issues/3121
或者
您可以尝试下拉菜单放置。 select2 在 Bootstrap 模态中无法正常工作...
如您在打印屏幕上所见,下拉菜单已向上呈现。谁能告诉我如何渲染它?
代码:
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 呈现下降的缺点。任何帮助问候。
我找到了一些可能对您有帮助的文档
有“forceabove”参数。
您应该可以将其更改为强制低于...
来源:https://github.com/select2/select2/issues/3121
或者
您可以尝试下拉菜单放置。 select2 在 Bootstrap 模态中无法正常工作...