How to select-deselect rows in PrimeNG Datatable?

Viewed 12250

I added multiple selection column and it is now able to select/ deselect rows manually in PrimeNG Datatable.

What I added:

<p-column [style]="{'width':'38px'}" selectionMode="multiple"></p-column>

I am expecting to unselect this rows after clicking a button which is in another column of data table. Is there any way to select/deselect primeNG datatable programmatically?

  • Angular Version: 4.2.4
  • PrimeNG Version: 4.3.0
1 Answers

You can access selected rows through selection property:

<p-dataTable [value]="cars" [(selection)]="selectedRows">

Then when you click on the button, you just have to assign an empty array to selectedRows:

this.selectedRows = [];

See working Plunker

Is that what you are looking for ?

Related