Since I could not find any information, I am writing here. How can I reset a selected value of igx-select using typescript:
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?
Hello Silvia,
Thank you for posting to Infragistics Community!
I have been looking into your question and my suggestion is to use an igx-icon in the igx-suffix of the select component. On the click event of the icon will execute a method that will be given two arguments: the cell and the event itself. In the method, you can set a new value to the cell as the placeholder or simply set an empty string, and with the event you can also prevent the drop-down container from opening. This will reset the igx-select value and achieve your requirements.
In addition, I have prepared a small sample illustrating my suggestion which could be found here.
Please test it on your side and let me know if you need any further assistance with this matter.
Regards,
Georgi Anastasov
Software Developer
Infragistics
I tried to adapt your example to my columns, but because of the event parameter (I suggest) I could not get it working.
Thank you for clarifying your requirement.
My suggestion is to use the getCellByColumn method of the grid to access the cell with the igx-select editor, for example:
public resetSelect(cell: IgxGridCell){ let previousCellOnRow = this.grid1.getCellByColumn(cell.id.rowIndex,'departament'); previousCellOnRow.value = 'Choose a departament'; }
Thus, its value could be reset upon clicking on a button in another column of the same row.
I have modified the previous sample illustrating my suggestion which could be found here.
Please test it on your side and let me know whether you find it helpful.
Hello,I am glad that you find my suggestion helpful. Thank you for using Infragistics components!
Perfect! Thank you very very much. The example was very helpful!