![](/img/trans.png)
[英]Primeng contextmenu with turbotable : how to remove row selection when closing the context menu
[英]Disable/Enable selection based on row content of PrimeNG TurboTable or TreeTable
使用 p-treeTable,我可以根據 selectionMode = "single" 啟用所有行的選擇。 現在我想禁用不打算選擇的行的選擇。
PrimeNG 7,角 7。
如果我刪除 tr 的主體模板的[ttRow]="rowNode" [ttSelectableRow]="rowNode"
,則所有行都不可選擇。
<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>
現在我需要根據行數據進行檢查,例如rowData.selectable', to enable/disable row selection based on the outcome of
rowData.selectable` rowData.selectable', to enable/disable row selection based on the outcome of
。 任何想法如何實現這一目標?
我知道這是一個老問題。 但是怎么樣:
<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>
我相信這就是 ttSelectableRowDisabled 的用途。 無論如何,它似乎都能勝任。
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode"
[ttSelectableRowDisabled]=!rowData.selectable>
<td *ngFor="let col of columns">
{{ rowData[col.field] }}
</td>
</tr>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.