<p-header>
<div class="ui-helper-clearfix">
List of Impound Vehicle
<button pButton type="button" (click)="showDialog(0)" style="float: right" icon="fa-save" class="ui-button-primary" label="Release"></button>
</div>
</p-header>
<p-column field="empAddress" header="Address" [style]="{'width':'150px'}" [sortable]="true" [filter]="checked" filterPlaceholder=""></p-column>
<p-column field="empGender" header="Gender" [style]="{'width':'100px'}"></p-column>
<p-column header="Action" [style]="{'width':'100px'}">
<ng-template let-viotor="rowData" pTemplate="body">
<button pButton type="button" icon="fa-list-ul" class="ui-button-success"></button>
<button pButton type="button" icon="fa-trash-o" class="ui-button-danger"></button>
</ng-template>
</p-column>
<ng-template pTemplate="paginatorLeft">
There are {{impoundList?.length}} impoundList recorded.
</ng-template>
当我点击数据表中的一行时,是否可以启用/禁用释放按钮..那么有人可以帮忙解决这个问题吗?
答案 0 :(得分:0)
将已禁用的属性分配给按钮
<button pButton type="button" [disabled]="isButtonDisabled"(click)="showDialog(0)" style="float: right" icon="fa-save" class="ui-button-primary" label="Release"></button>
将click事件分配给列并调用函数并更改按钮启用/禁用标志。我没有使用数据表,但对于turbo表,这是方法之一。
例如:
<tr>
<td *ngFor="let col of columns" [pSortableColumn]="true" (click)="changeButtonStatus();">
...
</td>
<tr>
在组件
中isButtonDisabled:boolean=true;
function changeButtonStatus(){
this.isButtonDisabled= true/false ( based on your logic).
}