Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

multi-select: Initializing selected items #294

Open
benri opened this issue Oct 12, 2014 · 1 comment
Open

multi-select: Initializing selected items #294

benri opened this issue Oct 12, 2014 · 1 comment

Comments

@benri
Copy link

benri commented Oct 12, 2014

Trying to load pre-selected items in the multi-select model is a bit buggy. After some experimenting I determined cases which would or would not work in loading them in this plunkr

It seems for some reason you can't directly push to the ng-model array, but you can set it to an array that accesses the items of your multi-select.
Though, I'm not sure if this behavior is intended

@reifi
Copy link

reifi commented Oct 14, 2014

EDIT : See http://stackoverflow.com/questions/26061411/angular-ui-select-fetch-data-from-remote-service for solution without modifications. (for remote loading)

That is because ui-select seems to accept selections only from data that is also shown as choices.
You could modify line 621 like this:
https://github.com/reifi/ui-select/blob/master/src/select.js#L621
and it will accept "unknown" selections without having choices

Also, as far as I got it right, the watcher at https://github.com/angular-ui/ui-select/blob/master/src/select.js#L239 has to be triggered so it will trigger the other watcher for $select.selected which handles model updates over $formatters... (triggered by https://github.com/angular-ui/ui-select/blob/master/src/select.js#L257) - I got a headache.

"Unknown" preselected items to the choices-datastore are necessary for remote loading (now done by refreshAsync). Also - for remote loading the selected selection has to be independent from choices datastore.

The concept itself how to cope with datastores seems to need rethinking. My wish would be to have something like an extjs combo with store (for its controller features, not DOM stuff)

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

No branches or pull requests

3 participants