ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Ionic 2 - Allow custom components for the Select input.

Open alexweber opened this issue 10 years ago • 4 comments

Short description of the problem:

At the moment we can pick between the default Alert style or a Popover style for the Select component, which is nice, but it'd be even nicer to do something more robust like show a list with toggles or checkboxes to get a richer display with icons, additional info etc (think of picking a contact from address book for example).

What behavior are you expecting?

It would be nice to able to specify a custom Modal component to be used for the Select options and have it emit a value on select using an interface contract or something.

Which Ionic Version? 1.x or 2.x 2

alexweber avatar Jun 17 '16 13:06 alexweber

Hi @alexweber,

Not saying we will or won't do this long term, but in the short term it shouldn't be too challenging to do something like this yourself. It's pretty easy to extend ViewController (like Modal, PopOver, Alert, Select, etc) and make your own component.

Thanks for the idea!

Thanks, Dan

danbucholtz avatar Jun 17 '16 14:06 danbucholtz

Hello @alexweber, thanks for opening an issue with us! It is actually currently possible to put a select element in a modal along with checkboxes, toggles etc and then either pass the selected data back to the previous page as a parameter of the onDismiss event that gets fired when the modal is dismissed, or using an eventEmitter. Thanks for using Ionic!

jgw96 avatar Jun 17 '16 14:06 jgw96

@jgw96 Hi, thanks for replying, I realize I can do this myself and I actually am doing something similar to work around it with a modal but what I couldn't achieve was a clean way to integrate it with the ion-select element. I wanted to listen on click and open my modal instead but haven't been able to cancel the default behavior of the select opening. I think i'll have to create my own custom select like @danbucholtz suggested. @danbucholtz Thanks!

alexweber avatar Jun 17 '16 16:06 alexweber

@jgw96 Hi, i am also trying to achieve something like this by default ionic gives alert on clicking ion-selct i want to remove the ok button and make the click happen when the user select the option and it should close. is it possible or is there any way we can achieve can you share you code

gopi2mohan avatar Dec 01 '16 17:12 gopi2mohan