Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deselect single row from mat-table

I'm using the Selection Data table

to deselect all the rows we use:

this.selection.clear();

where selection is an object of SelectionModel class. Now what if I want to remove the selection of specific row from code behind "component typescript code", is there any helpful "angular" statement just like clear() method?

like image 983
userx Avatar asked Dec 24 '22 08:12

userx


1 Answers

You can use

this.selection.deselect(row)

this.selection.select(row)

Sample to deselect 5th row with mat-table

function to do select or deselect specific row.

Example: If you want to deselect 3rd row you can do following.

this.selection.deselect(this.dataSource.data[2])

This the SelectionModel class code

like image 67
Yogen Darji Avatar answered Dec 25 '22 21:12

Yogen Darji