onRowUnselect event not firing in Angular2

1k views Asked by At

I am using Angular2 with PrimeNG components. In <p-datatable>, the onRowUnselect event is not firing.

Here is my sample code:

<p-dataTable [value]="incidentData" [rows]="3" reorderableColumns="true" (onRowClick)="onRowSelectInvestigation($event)" (onRowUnselect)="onRowUnselect($event)" [(selection)]="selectedIncident">
2

There are 2 answers

1
BillF On

You need to add selectionMode="single" to get that method to work.

0
TimeTraveler On

Add selectionMode="single"

Set [metaKeySelection]="false" which turn off metakey so that we can unselect a selected row by clicking on it.

Otherwise click a selected row with ctrl like ctrl+click to unselect it.

Also onRowUnselect won't be called when switching row selection.

Statement from primeng document -> onRowUnselect -> Callback to invoke when a row is unselected with metakey.