2021-12-24

p-multiSelect onchange prevent adding elements with the same index

I have multiselect option with 6 options from array. one of the option is a bit diffrent then the others(it lets adding remark and in the others not). when I am selecting this option and one of the fields x(the remark), after I removing it and selecting again but the field will be null (lets say in the first case I am adding reark and in the second time I'm not) so the multi select will add it twice! but I want 1 velue for every index(without care of the other fields).how should I do it? another place it different in getting the selected values from the server, when it should be selected after the user choosed it it seemes like he didn't choose.

  <p-multiSelect *ngIf="_decision.decisionStatusId == eDecisionType.Reject || _decision.decisionStatusId == eDecisionType.ReturnedToUser" [required]="formGroup.hasError('remark-reasons-required')"
                   [options]="reasons" defaultLabel="" formControlName="remarks" [(ngModel)]="selectedReasons" optionLabel="hebName"
                   [ngClass]="_decision.decisionStatusId == eDecisionType.ReturnedToUser || _decision.decisionStatusId == eDecisionType.Reject ? '' : 'display-none'"
                   selectedItemsLabel="{0} "
                   (onChange)="onChangeReasonsValue($event)"></p-multiSelect>

.ts

onChangeReasonsValue(event: { value: ReviewDecisionReasonModel[] }): void {
    this.selectedReasons = event.value;
    this._decision.reasons = event.value;
    this.formGroup.markAsDirty();
    this.formGroup.markAsTouched();
    this.formGroup.updateValueAndValidity();
  }

same index values



from Recent Questions - Stack Overflow https://ift.tt/3yTbFa3
https://ift.tt/eA8V8J

No comments:

Post a Comment