Reputation: 149
With p-treeTable i can enable selection for all rows, based on selectionMode = "single". Now i'd like to disable selection for rows, which are not intended to be selected.
PrimeNG 7, Angular 7.
If I remove [ttRow]="rowNode" [ttSelectableRow]="rowNode"
of tr's body template, all rows are not selectable.
<p-treeTable [value]="nodes" [columns]="columns" selectionMode="single"
[(selection)]="selectedNode" dataKey="id" >
...
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<td *ngFor="let col of columns">
{{ rowData[col.field] }}
</td>
</tr>
</ng-template>
</p-treeTable>
Now i need a check based on the row data, e.g. rowData.selectable', to enable/disable row selection based on the outcome of
rowData.selectable`.
Any ideas how to achieve this?
Upvotes: 2
Views: 2844
Reputation: 291
I believe that's what ttSelectableRowDisabled is for. It seems to do the job anyway.
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode"
[ttSelectableRowDisabled]=!rowData.selectable>
<td *ngFor="let col of columns">
{{ rowData[col.field] }}
</td>
</tr>
Upvotes: 1
Reputation: 120
I know this is an old question. But how about something like:
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode" *ngIf=rowData.selectable>
<td *ngFor="let col of columns">
{{ rowData[col.field] }}
</td>
</tr>
<tr [ttRow]="rowNode" *ngIf=!rowData.selectable>
<td *ngFor="let col of columns">
{{ rowData[col.field] }}
</td>
</tr>
Upvotes: 0