PrimeNG 多选选择和取消选择值 [英] PrimeNG multiselect select and deselect value

查看:111
本文介绍了PrimeNG 多选选择和取消选择值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在primeNG多选中我们如何知道值/对象是被选中还是被取消选中.

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 总是返回最新的选定值数组event.itemValue 返回选中/未选中的值

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.

任何帮助将不胜感激.

谢谢PG

推荐答案

虽然这个问题问了好久才回答,但可能会帮到别人.

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

event.value:当前选择的值数组

event.value: Current selected values array

event.itemValue:切换的项目值

event.itemValue: Toggled item value

要确定复选框是选中还是取消选中,只需检查 event.itemValue 是否存在于 event.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.

@谢谢

这篇关于PrimeNG 多选选择和取消选择值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆