elm-ui-dropdown icon indicating copy to clipboard operation
elm-ui-dropdown copied to clipboard

Support for loading and searching dropdown items via ajax

Open aszenz opened this issue 4 years ago • 2 comments

Thanks for creating this package.

I would like to know if there's a way to load items lazily via ajax requests, we have drop-downs with hundreds of items that cannot be preloaded.

On a related note it would be great if searching could also be done via ajax requests.

The best example of this currently is jQuery based select2 and react based react-select.

aszenz avatar May 04 '21 17:05 aszenz

I would like to know if there's a way to load items lazily via ajax requests

You can use anything that can transform into an array of objects, but I would recommend showing a spinner when loading the data, approaching a state-machine like this: http://blog.jenkster.com/2016/06/how-elm-slays-a-ui-antipattern.html

If searching could also be done via ajax requests.

Right now search is done by filtering locally, we can accept that as a feature if someone is interested in submitting a PR.

EDIT: For reference: https://package.elm-lang.org/packages/PaackEng/elm-ui-dropdown/latest/Dropdown#filterable

PedroHLC avatar May 10 '21 15:05 PedroHLC

You can use anything that can transform into an array of objects, but I would recommend showing a spinner when loading the data, approaching a state-machine like this: http://blog.jenkster.com/2016/06/how-elm-slays-a-ui-antipattern.html

So when it's a big drop down list I can't get an array of objects all at once, ideally i would load 10 options, show them when the user opens the drop down and then once the user scrolls past these 10 options, load 10 more and so on. This will require a paginated api, to which the drop down can send commands to. Similarly filtering would work based on an api.

Admittedly this is a complex requirement but it's been implemented before in elm by https://github.com/MadonnaMat/elm-select-two

aszenz avatar May 18 '21 16:05 aszenz