Reset igx-select

361 Views Asked by At

Since I could not find any information, I am writing here. How can I reset a selected value of igx-select using typescript:

enter image description here

Here is my HTML-Code:

        <igx-select #selectDepartment
             placeholder="Wähle Abteilung"
             [overlaySettings]="overlaySettings"
             [ngClass]="[cell.row.deleted?'upfont' : 'drop-down-grid']"
             [(ngModel)]="cell.value">
         <igx-select-item style="font-size: 12px;" *ngFor="let item of arrayDepartments" [value]="item">
           {{ item }}
         </igx-select-item>
       </igx-select>

Is there any way to delete the value of the cell and show the placeholder when for example a button is clicked?

1

There are 1 best solutions below

0
Konstantin Dinev On

You can use the clearSelection method exposed by the IgxSelectComponent.

<igx-select #selectDepartment
     placeholder="Wähle Abteilung"
     [overlaySettings]="overlaySettings"
     [ngClass]="[cell.row.deleted?'upfont' : 'drop-down-grid']"
     [(ngModel)]="cell.value">
 <igx-select-item style="font-size: 12px;" *ngFor="let item of arrayDepartments" [value]="item">
   {{ item }}
 </igx-select-item>
</igx-select>
<button igxButton (click)="reset(selectDepartment)">Reset</button>
public reset(select: IgxSelectComponent) {
    select.clearSelection();
}

Here's a stackblitz example.