0

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.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
99Coder
  • 47
  • 1
  • 7

1 Answers1

0

My mistake is that I did push in wrong way

Wrong:
this.selection.push(item);

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

99Coder
  • 47
  • 1
  • 7