Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select-deselect rows in PrimeNG Datatable?

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
like image 446
Laxmikant Dange Avatar asked Nov 23 '17 05:11

Laxmikant Dange


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 ?

like image 175
Antikhippe Avatar answered Oct 25 '22 13:10

Antikhippe