# Add a Select all to a ionic-select box

**URL:** <https://forum.ionicframework.com/t/add-a-select-all-to-a-ionic-select-box/150293>\
**Category:** ionic-v3\
**Created:** [December 13, 2018, 11:00pm UTC](https://forum.ionicframework.com/t/add-a-select-all-to-a-ionic-select-box/150293 "2018-12-13T23:00:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![helpmelearn](https://avatars.discourse-cdn.com/v4/letter/h/f0a364/32.png) [@helpmelearn](https://forum.ionicframework.com/u/helpmelearn)\
**Post date:** [December 13, 2018, 11:00pm UTC](https://forum.ionicframework.com/t/add-a-select-all-to-a-ionic-select-box/150293/1 "2018-12-13T23:00:23Z")

</div>

Right now we have a multi-select box. They wanted some way to add a select all to it.  
I knew the select box used some alert values so my original idea was to add a third button that would toggle the list, either select them all or deselect them all.

Not as easy as I would like. Even though the documentation for ion-select does say it uses the options that alert controller has, there is no way that I can see to add or even change the buttons. (only the title).

Next is adding in an extra row with this.  
(ionSelect)="selectAll($event)

As far as I can tell this only gets called when the checkbox is being checked, when it gets unchecked it doesn’t fire.  
Is there an easy way to do this?

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [December 13, 2018, 11:22pm UTC](https://forum.ionicframework.com/t/add-a-select-all-to-a-ionic-select-box/150293/2 "2018-12-13T23:22:43Z")

</div>

> [@helpmelearn](#):
>
> Is there an easy way to do this?

Not that I’m aware of. I think you would have to completely roll your own.

---

<div class="post-metadata">

**Author:** ![helpmelearn](https://avatars.discourse-cdn.com/v4/letter/h/f0a364/32.png) [@helpmelearn](https://forum.ionicframework.com/u/helpmelearn)\
**Post date:** [December 13, 2018, 11:41pm UTC](https://forum.ionicframework.com/t/add-a-select-all-to-a-ionic-select-box/150293/3 "2018-12-13T23:41:24Z")

</div>

Not what I wanted to hear.

I do find it strange that (ionSelect) only fires when the item is getting checked. Should this fire both ways?  
I guess for some reason my expectation is the user clicks the check box, ionSelect fires either with a true or false or checked or unchecked, some value on what just happen.

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [December 14, 2018, 12:21am UTC](https://forum.ionicframework.com/t/add-a-select-all-to-a-ionic-select-box/150293/4 "2018-12-14T00:21:19Z")

</div>

> [@helpmelearn](#):
>
> Should this fire both ways?

Sort of depends on what you mean by “should”. If you mean “is it supposed to work that way?”, [no](https://github.com/ionic-team/ionic-v3/blob/master/src/components/select/select.ts):

```auto
   // Only emit the select event if it is being checked
   // For multi selects this won't emit when unchecking
   if (selectedOption.checked) {
     input.ionSelect.emit(input.value);
   }

```

---

<div class="post-metadata">

**Author:** ![helpmelearn](https://avatars.discourse-cdn.com/v4/letter/h/f0a364/32.png) [@helpmelearn](https://forum.ionicframework.com/u/helpmelearn)\
**Post date:** [December 14, 2018, 3:12pm UTC](https://forum.ionicframework.com/t/add-a-select-all-to-a-ionic-select-box/150293/5 "2018-12-14T15:12:27Z")

</div>

Thanks for the info. I don’t know if that is ionic code? But looking at that it wouldn’t be that hard to add another if statement. I’m assuming checked is a boolean. true for being checked false for being unchecked. I know I’m not seeing the full picture.

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [December 14, 2018, 7:13pm UTC](https://forum.ionicframework.com/t/add-a-select-all-to-a-ionic-select-box/150293/6 "2018-12-14T19:13:00Z")

</div>

> [@helpmelearn](#):
>
> I don’t know if that is ionic code?

The word “no” is a hyperlink.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:03pm UTC](https://forum.ionicframework.com/t/add-a-select-all-to-a-ionic-select-box/150293/7 "2021-07-19T21:03:48Z")

</div>

Closed on July 19, 2021, 9:03pm UTC


