[英]How to disable primeng multiselect dropdown options of respective multiselect dropdown when a value is changed in a loop
I am using primeng v6.x multiselect inside a table where data rendered dynamically in a loop.我在一个表中使用 primeng v6.x 多选,其中数据在一个循环中动态呈现。
My options array looks as follows:我的选项数组如下所示:
let data = [
{ key: "ALL", desc: "All", disabled: false },
{ key: "PQR", desc: "Pqr", disabled: false },
{ key: "XYZ", desc: "Xyz", disabled: false }
];
I am passing the above array in [options]="data"
.我在
[options]="data"
中传递上面的数组。 I have an add button, when click a new row will be added to the table.我有一个添加按钮,当单击时,新行将添加到表中。
Expected behavior: When select "ALL"
option I am changing disabled property to true where it should disable remaining options only in that particular row's dropdown.预期行为:当 select
"ALL"
选项时,我将 disabled 属性更改为 true,它应该仅在该特定行的下拉列表中禁用其余选项。
Issue: It disables all remaining options in all the table rows including original variable.问题:它禁用所有表行中的所有剩余选项,包括原始变量。 Please suggest me the solution.
请给我建议解决方案。
HTML: HTML:
<p-multiSelect [options]="data" (onChange)="changeEvent($event)" optionLabel="desc" dataKey="key" [formControl]="dataListControl"></p-multiSelect>
Yes, I am passing a common variable in options.是的,我在选项中传递了一个公共变量。 Tried different ways like created new control when adding new row and bind the data into options (not sure if it is correct way), it updates original variable value also.
尝试了不同的方法,比如在添加新行时创建新控件并将数据绑定到选项中(不确定它是否正确),它也会更新原始变量值。 Please suggest how to make optional value unique to specific row.
请建议如何使特定行的可选值唯一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.