Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select 2 dont show all values #117

Open
hellerEkc opened this issue Jun 12, 2020 · 0 comments
Open

Select 2 dont show all values #117

hellerEkc opened this issue Jun 12, 2020 · 0 comments

Comments

@hellerEkc
Copy link

Hi, I have select 2, which may shown more than 1400 values in combobox. Unfortunately values is somhow cut, and it didnt display all values. Any help will be appreciated. Here is code:

originStationDropDown = new Select2Choice<>("originDgfStation", new PropertyModel<Station>(this, "originStation") , new StationsProvider(originCountryDD, productDD));
 ;
private class StationsProvider extends ChoiceProvider<Station> {

        private Select2Choice<Country> countryDD;
        private DropDownChoice<Product> productDD;

        public StationsProvider(Select2Choice<Country> countryDD, DropDownChoice<Product> productDD) {
            this.countryDD = countryDD;
            this.productDD = productDD;
        }

        @Override
        public void query(String codeNameFragment, int i, Response<Station> response) {
            if(codeNameFragment == null || "".equals(codeNameFragment)) {
                List<Station> stations = stationDao.findByCountryAndProduct(countryDD.getModel().getObject(), productDD.getModel().getObject(), "code");
                for(Station station : stations) {
                    response.add(station);
                }
            } else {
                response.addAll(stationDao.findByCountryAndProductAndFragment(countryDD.getModel().getObject(), productDD.getModel().getObject(), codeNameFragment));
            }
            System.out.println(response.size());
        }

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

        @Override
        public Collection<Station> toChoices(Collection<String> collection) {
            List<Station> stations = new ArrayList<>();
            List<Station> stationList = stationDao.findAll();

            for(String id : collection) {
                for(Station station : stationList) {
                    if(station.getId().equals(Long.valueOf(id))) {
                        stations.add(station);
                    }
                }
            }
            return stations;
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant