pawangera
pawangera

Reputation: 71

PrimeNG multiselect select and deselect value

How do we know in primeNG multiselect whether value/object is selected or deselected.

https://www.primefaces.org/primeng/#/multiselect

    onChange    event.originalEvent: browser event
    event.value: Current selected values
    event.itemValue: Toggled item value

event.value always return the latest array of selected values event.itemValue returns the selected/unselected value

I found in the documentation these three events and in debugging I didn't find any selection and deselection attribute.

Any help would be highly appreciated.

Thanks PG

Upvotes: 1

Views: 4626

Answers (2)

aruninayak
aruninayak

Reputation: 21

Although I am answering it after a long time the question has asked, but it will help others may be.

event.value: Current selected values array

event.itemValue: Toggled item value

To identify whether the checkbox selected or deselected, just check the event.itemValue is present in the event.value array.

if found in the array then selected otherwise take as deselected.

@Thanks

Upvotes: 2

Manoj Rajput
Manoj Rajput

Reputation: 1

var checked = false;
if (event.value.map((a) => a.id == event.itemValue.id).length == 1) {
    checked = true;
}

Upvotes: 0

Related Questions