设计人员的 UI 模拟要求我将全局搜索过滤器移到 p 表之外,但我不确定如何执行此操作,或者是否可能?有没有人有做类似事情的经验?我可以严格使用 CSS 样式来做到这一点,同时保持针对不同屏幕尺寸的响应式布局吗?
<p-table #dt [value]="tags" [paginator]="true" [rows]="25" [columns]="cols" [resizableColumns]="true" [globalFilterFields]="['vendor']">
<ng-template pTemplate="caption">
<div style="text-align: right; overflow-x: hidden;">
<p class="wrapper"><input type="text" class="search-vendors" pInputText size="50" placeholder="Search Vendors" (input)="dt.filterGlobal($event.target.value, 'contains')" style="width:auto"></p>
</div>
</ng-template>
<ng-template pTemplate="header" let-columns>
<tr>
<th class="{{col.class}}" *ngFor="let col of columns" [pSortableColumn]="col.field">
<p-sortIcon [field]="col.field" *ngIf="col.field == 'fieldThree' || col.field == 'fieldOne' || col.field == 'fieldTwo' "></p-sortIcon>
{{col.header}}
<fa *ngIf="col.field == 'fieldThree' || col.field == 'fieldTwo'" name="info-circle" pTooltip="{{col.tooltip}}" tooltipPosition="right" showDelay="1000" hideDelay="500"></fa>
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData let-columns="cols">
<tr [pSelectableRow]="rowData">
<td *ngFor="let col of cols" [ngClass]="{'toggle-tag': col.field==''}">
<div *ngIf="col.field == 'fieldThree'; then vendorRow"></div>
<div *ngIf="col.field == 'fieldTwo' || col.field == 'domain' || col.field == 'fieldThree'; then default"></div>
<ng-template #vendorRow><a (click)="showVendorDetails(rowData)">{{rowData[col.field]}}</a></ng-template>
<ng-template #default>{{rowData[col.field]}}</ng-template>
</td>
</tr>
</ng-template>
</p-table>
Run Code Online (Sandbox Code Playgroud)
是的,这是可能的。只需删除ng-template pTemplate="caption"内部的块p-table并在外部具有完全相同的输入字段(如下所示)p-table
<input type="text" class="search-vendors" pInputText size="50" placeholder="Search Vendors"
(input)="dt.filterGlobal($event.target.value, 'contains')" style="width:auto">
Run Code Online (Sandbox Code Playgroud)
这与它在p-table. 然后你可以在上面添加任何CSS(以使其响应式等)。保留其余p-table代码不变。
关注官方文档
| 归档时间: |
|
| 查看次数: |
3642 次 |
| 最近记录: |