I am using primeNG v7.0.3 and i'd like to disable some option in a multiselect component.
However I did everything as mentioned in the documentation it's still selectable as an option.
[options]="roleOptions"
and initialized as: roleOptions: SelectItem[];
then later populated with a function called by ngOnInit
.
If need more clarification let me know.
How can I disable some of my options conditionally in a p-multiselect component?
@Edit:
What I've tried so far: This issue here on stack overflow
ngOnInit() {
this.translateInit().then(() => {
this.setStatusOptions();
this.setUserRoles();
});
this.setEditing();
}
private setUserRoles() {
this.roleOptions = [
{ label: this.messages['GLOBAL.USER.ROLE.CLINIC_USER'], value: this.roleEnum.CLINICUSER, disabled: true },
{ label: this.messages['GLOBAL.USER.ROLE.AGENT_USER'], value: this.roleEnum.AGENTUSER },
{ label: this.messages['GLOBAL.USER.ROLE.ADMIN_USER'], value: this.roleEnum.ADMINUSER },
{ label: this.messages['GLOBAL.USER.ROLE.CLINIC_REVIEWER'], value: this.roleEnum.CLINICREVIEWER }
];
}
If I try the solution that I've linked I'll get the following:
@Edit2 /SOLUTION/:
In the template you need to remove optionLabel="label" in order to use this method now it's disabled. However the documentation should mention this I think.
Fun fact! You don't need the above mentioned solution for this to work, simply remove optionLabel from template and it's working...