How could I select automatically a row in dataTable after a given record? The dataTable has sorted column, and pagination. After a given record I would expect the record to be selected on the page that exists.
The dataTable has a property(an array) called [(selection)]
, to add/remove/preselect rows you can just add/remove values from your array
to pre-select the nth
:
component:
ngOnInit() {
this.data = [/*data*/];
this.selectedItems = [ this.data[n-1]];
}
template:
<p-dataTable [value]="data" [(selection)]="selectedItems">