That’s a cool, simple solution, rdlabo. But really, the “All” button should appear as the top option in the selection list. When you click it, all options become selected, when you click it again, all options are de-selected. (Or maybe just put in small “All” and “None” buttons.) It would be nice to have this functionality built in automatically, maybe optionally, when multiple=“true”.
It renders the all option but the allClicked() event triggers only when setting the option, and not when you toggle it off. In addition, when I get into the allClicked() handler, there doesn’t seem to be a way to control the selection of the rest of the options.
allClickedCategories() {
this.categories = [];
for (var i = 0; i < this.categoriesitems.length; i++) {
this.categories.push(this.categoriesitems[i].name)
}
}
but when i click on this button the flag near the option don’t show but this options are in array and when i click again on the select i show the flag.
There is an option to refresh the select or a method that does this?
Anybody get this working for Ionic 3? I tried adding my own check box to the list, no go. Instead of ionSelect to use a click even and see if people have turned it on or off. No go.
Any idea?
(Really I wish I could add another button to the bottom for Select All but that doesn’t seem to work either).
You make things challenging when necromancing a very muddy thread asking about something as vague as “this”. IMHO, the attempt to shoehorn a “select all” option into the <ion-select> itself is misguided, as it introduces a category error - making one of the options in an option menu not really be an option at all. I would definitely make any attempt at “select all” functionality live outside of the select, perhaps as a checkbox or toggle.
So what exactly are you trying to achieve, what code do you have to attempt it, and what exactly is the disconnect between those two things?
Trying to get some Select All (and or Deselect All) working with ion-select.
The ideal way would be have some button outside the list but in the popup. Ok, Cancel, Select All. This does not seem doable. Ionic only allows for the two buttons as far as I can see.
Next option is what is being tried here, adding some option to the list.
Doing how it was implement here <ion-option (ionSelect)="allClickedCategories()">Select/Deselect All</ion-option>
I get the same results.
1- ionSelect only fires when the user clicks it, not when they un-checked it.
2. It seems like when the list items are generated they are static and can’t be updated on the fly.
What I’m seeing — List of Items have values unchecked, open up select list with items un-checked. Click the select all, code runs to put items in the check state but screen does not reflect this. user can click cancel and the items are now checked.
Last options I’m trying is just using a normal check box.
The check box shows up correctly. I click the check box but the selectAll code is never called. Debugging more in a browser I can follow the click event listener is firing. (Code in tap-Click.js is hit). But again never reaches selectAll.
I think even I got this problem fixed, I would still have problem #2 above.