问题
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
回答1:
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
回答2:
var checked = false;
if (event.value.map((a) => a.id == event.itemValue.id).length == 1) {
checked = true;
}
来源:https://stackoverflow.com/questions/53957352/primeng-multiselect-select-and-deselect-value