So, what is " /> So, what is " /> So, what is "/>

PrimeNG p-table - Cannot push item (row) into 'selection''

817 views Asked by At

I am using Angular 9, PrimeNG p-table component.

<p-table [value]="cars" selectionMode="multiple" dataKey="id" [(selection)]="selection">

So, what is a problem.

I have 5 rows and for each row I have checkbox. When I select some row or rows, 'selection' is populated and checkboxes are 'checked' but when I manually pust item to 'selection' list - I can't see checked rows until I click on some row checkbox.

Reason why I want to do this is because I have input fields in row/s so when I change input value, I would call a method that will automatically preselect that row as 'checked' in checkbox.

1

There are 1 answers

0
99Coder On

My mistake is that I did push in wrong way

Wrong:
this.selection.push(item);

Good: [...this.selection,item]