简体   繁体   English

如何在循环中更改值时禁用相应多选下拉列表的 primeng 多选下拉选项

[英]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.请建议如何使特定行的可选值唯一。

  • if you are using formArray then it should've been working, can you please share your html and ts file, so I can check what's causing the problem, right now you only share the component and it's options, so it's hard to understand.如果您使用的是 formArray 那么它应该一直在工作,请您分享您的 html 和 ts 文件,这样我可以检查导致问题的原因,现在您只分享组件及其选项,所以很难理解。 It would be great if you create a stackblitz .如果您创建一个stackblitz就太好了。 thank you谢谢你

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在多选下拉菜单中禁用 2 个选项并将该选项变灰 - How to disable 2 options in multiselect dropdown and grayout that option 在 PrimeNG 中单击多选下拉列表中的字段时禁用多选下拉关闭 - Disable dropdown close of multiselect on click of a field inside multiselect dropdown in PrimeNG 如何以反应形式修补多选下拉列表(primeng 组件)的值? - How to patch the value of multiselect dropdown (primeng component) in a reactive form? 如何绑定primeng Angular的多选下拉数据 - How to bind data of multiselect dropdown of primeng Angular 基于另一个多选下拉 PrimeNg 的值未填充到多选下拉值中 - Values are not populating in multiselect dropdown values based on another multiselect dropdown PrimeNg primeng - 在页面加载时显示多选下拉菜单? - primeng - on page load show the multiselect dropdown? 多选下拉控件 - Primeng - Angular 6 - 在页面加载时默认选择所有选项并将它们显示为选定标签 - Multiselect dropdown control - Primeng - Angular 6 - Select all options by default on page load and display them as selected label 如何检查Angle2下拉多选的所有选项 - How to do checkAll options for angular2 dropdown multiselect 如何在 Typescript 中动态禁用或启用 ng-multiselect-dropdown - How to, dynamically disable or enable a ng-multiselect-dropdown in Typescript 根据从另一个primeNg多选下拉列表中选择/取消选择的值,从primeNg多选下拉列表中添加/删除项目/值 - Add/Remove items/values from primeNg multiselect dropdown based on values selected/deselected from another primeNg multiselect dropdown
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM