Closed zeropy009 closed 1 year ago
Is this what you are looking for? https://github.com/ionic-selectable/ionic-selectable/wiki#hasconfirmbutton
Is this what you are looking for? https://github.com/ionic-selectable/ionic-selectable/wiki#hasconfirmbutton
my project isMultiple = "true" so hasConfirmButton always true. I just want check a condition when click an item to control the item "selected" or "not selected" I was try change event.isSelected = false; in onSelect() but it still "selected"
So what exactly do you want to happen when you click an item?
So what exactly do you want to happen when you click an item?
I want to control its selection state according to my selection
You can use (onSelect)="onSelect($event)">
event and update a related item (sync its selection state) as shown below.
public onSelect(event): void {
event.item.isSelected = event.isSelected;
}
Note that item.isSelected
is a custom property of your item, you can call it what you like, whereas event.isSelected
is a read-only property of the ionic-selectable event.
Also, if you wish to exclude some items from the selection, but keep them visible in the list you can disable those items. Disabled items cannot be selected. https://github.com/ionic-selectable/ionic-selectable/wiki#disableditems
vent.isSelected
is a read-only property of the ionic-selectable event.
my project need check condition then ask user to confirm check or not check so can't disable it. Thank for help.
Is the issue solved?
Is the issue solved?
I think i must custom ionicSelectableItemTemplate no more choice, I don't know why event.isSelected is a read-only property, it should can set value xD
It's a read-only property for a reason. It doesn't belong to an item but simply tells whether the item has been selected or unselected. If it was allowed to set event.isSelected
property then the component would need to automatically update its value ([(ngModel)]
or [formControl]
), which kind of smells.
So in your case, if you want to unselect the selected item based on a condition then you should change the component's value via [(ngModel)]
or [formControl]
manually.
In addition, it looks like a UX issue to unselect an item that has just been selected. I would try to avoid it and instead apply a validation so that users can select any items but a validation would show a message saying that the selected item isn't correct because it violates some business rules of the app.
how can confirm an item when I click it before add it to selected list of ionic-selectable ? I was try with : onSelect(event: { component: IonicSelectableComponent, isSelected: boolean, item: Service }) { if (event.isSelected) { let userResult : boolean; userResult = ..... // ask user to select it or not select event.isSelected = userResult; } }
But it not working, please help me Thank you.