nx-primeng-sakai-v17/src/app/demo/view/tabledemo.component.html

304 lines
13 KiB
HTML
Raw Normal View History

2021-12-09 14:24:42 +00:00
<div class="grid table-demo">
<div class="col-12">
<div class="card">
<h5>Filter Menu</h5>
2021-12-21 07:14:39 +00:00
<p-table #dt1 [value]="customers1" dataKey="id" [rows]="10" [loading]="loading" styleClass="p-datatable-gridlines" [paginator]="true" [globalFilterFields]="['name','country.name','representative.name','status']" responsiveLayout="scroll">
2021-12-09 14:24:42 +00:00
<ng-template pTemplate="caption">
2021-12-21 07:14:39 +00:00
<div class="flex justify-content-between flex-column sm:flex-row">
<button pButton label="Clear" class="p-button-outlined mb-2" icon="pi pi-filter-slash" (click)="clear(dt1)"></button>
<span class="p-input-icon-left mb-2">
2021-12-09 14:24:42 +00:00
<i class="pi pi-search"></i>
2021-12-21 12:15:22 +00:00
<input pInputText type="text" #filter (input)="dt1.filterGlobal($event.target.value, 'contains')" placeholder="Search Keyword" class="w-full"/>
2021-12-09 14:24:42 +00:00
</span>
</div>
</ng-template>
<ng-template pTemplate="header">
<tr>
<th>
<div class="flex justify-content-between align-items-center">
2021-12-09 14:24:42 +00:00
Name
2021-12-21 12:15:22 +00:00
<p-columnFilter type="text" field="name" display="menu" placeholder="Search by name"></p-columnFilter>
2021-12-09 14:24:42 +00:00
</div>
</th>
<th>
<div class="flex justify-content-between align-items-center">
2021-12-09 14:24:42 +00:00
Country
2021-12-21 12:15:22 +00:00
<p-columnFilter type="text" field="country.name" display="menu" placeholder="Search by country"></p-columnFilter>
2021-12-09 14:24:42 +00:00
</div>
</th>
<th>
<div class="flex justify-content-between align-items-center">
2021-12-09 14:24:42 +00:00
Agent
<p-columnFilter field="representative" matchMode="in" display="menu" [showMatchModes]="false" [showOperator]="false" [showAddButton]="false">
<ng-template pTemplate="header">
<div class="px-3 pt-3 pb-0">
2021-12-21 10:20:09 +00:00
<span class="font-bold">Agent Picker</span>
</div>
</ng-template>
<ng-template pTemplate="filter" let-value let-filter="filterCallback">
2021-12-21 12:15:22 +00:00
<p-multiSelect [ngModel]="value" [style]="{'min-width': '12rem'}" [options]="representatives" placeholder="Any" (onChange)="filter($event.value)" optionLabel="name">
<ng-template let-option pTemplate="item">
<div class="p-multiselect-representative-option">
2021-12-21 12:15:22 +00:00
<img [alt]="option.label" src="assets/demo/images/avatar/{{option.image}}" width="32" style="vertical-align: middle" />
<span class="ml-2">{{option.name}}</span>
</div>
</ng-template>
</p-multiSelect>
</ng-template>
</p-columnFilter>
2021-12-09 14:24:42 +00:00
</div>
</th>
<th>
<div class="flex justify-content-between align-items-center">
2021-12-09 14:24:42 +00:00
Date
2021-12-21 12:15:22 +00:00
<p-columnFilter type="date" field="date" display="menu" placeholder="mm/dd/yyyy"></p-columnFilter>
</div>
</th>
<th>
<div class="flex justify-content-between align-items-center">
Balance
<p-columnFilter type="numeric" field="balance" display="menu" currency="USD"></p-columnFilter>
2021-12-09 14:24:42 +00:00
</div>
</th>
<th>
<div class="flex justify-content-between align-items-center">
2021-12-09 14:24:42 +00:00
Status
<p-columnFilter field="status" matchMode="equals" display="menu">
<ng-template pTemplate="filter" let-value let-filter="filterCallback">
2021-12-21 12:27:33 +00:00
<p-dropdown [ngModel]="value" [options]="statuses" (onChange)="filter($event.value)" placeholder="Any" [style]="{'min-width': '12rem'}" >
<ng-template let-option pTemplate="item">
<span [class]="'customer-badge status-' + option.value">{{option.label}}</span>
</ng-template>
</p-dropdown>
</ng-template>
</p-columnFilter>
2021-12-09 14:24:42 +00:00
</div>
</th>
<th>
<div class="flex justify-content-between align-items-center">
2021-12-09 14:24:42 +00:00
Activity
<p-columnFilter field="activity" matchMode="between" display="menu" [showMatchModes]="false" [showOperator]="false" [showAddButton]="false">
<ng-template pTemplate="filter" let-filter="filterCallback">
2021-12-21 12:27:33 +00:00
<p-slider [ngModel]="activityValues" [range]="true" (onSlideEnd)="filter($event.values)" styleClass="m-3" [style]="{'min-width': '12rem'}" ></p-slider>
<div class="flex align-items-center justify-content-between px-2">
<span>{{activityValues[0]}}</span>
<span>{{activityValues[1]}}</span>
</div>
</ng-template>
</p-columnFilter>
</div>
</th>
<th style="width: 8rem">
<div class="flex justify-content-between align-items-center">
Verified
<p-columnFilter type="boolean" field="verified" display="menu"></p-columnFilter>
2021-12-09 14:24:42 +00:00
</div>
</th>
</tr>
2021-12-21 12:27:33 +00:00
</ng-template>
2021-12-09 14:24:42 +00:00
<ng-template pTemplate="body" let-customer>
<tr>
2021-12-21 12:15:22 +00:00
<td style="min-width: 12rem;">
2021-12-09 14:24:42 +00:00
{{customer.name}}
</td>
2021-12-21 12:15:22 +00:00
<td style="min-width: 12rem;">
<img src="assets/demo/flags/flag_placeholder.png" [class]="'flag flag-' + customer.country.code" width="30">
<span class="image-text ml-2">{{customer.country.name}}</span>
2021-12-09 14:24:42 +00:00
</td>
2021-12-21 12:15:22 +00:00
<td style="min-width: 14rem;">
<img [alt]="customer.representative.name" src="assets/demo/images/avatar/{{customer.representative.image}}" width="32" style="vertical-align: middle"/>
<span class="image-text ml-2">{{customer.representative.name}}</span>
2021-12-09 14:24:42 +00:00
</td>
2021-12-21 12:15:22 +00:00
<td style="min-width: 10rem;">
2021-12-09 14:24:42 +00:00
{{customer.date | date: 'MM/dd/yyyy'}}
</td>
2021-12-21 12:15:22 +00:00
<td style="min-width: 10rem;">
{{customer.balance | currency:'USD':'symbol'}}
</td>
2021-12-21 12:15:22 +00:00
<td style="min-width: 12rem;">
2021-12-09 14:24:42 +00:00
<span [class]="'customer-badge status-' + customer.status">{{customer.status}}</span>
</td>
2021-12-21 12:15:22 +00:00
<td style="min-width: 12rem;">
2021-12-09 14:24:42 +00:00
<p-progressBar [value]="customer.activity" [showValue]="false"></p-progressBar>
</td>
2021-12-21 12:15:22 +00:00
<td class="text-center" style="min-width: 8rem;">
<i class="pi" [ngClass]="{'true-icon pi-check-circle text-green-500': customer.verified, 'false-icon pi-times-circle text-pink-500 ': !customer.verified}"></i>
2021-12-09 14:24:42 +00:00
</td>
</tr>
</ng-template>
<ng-template pTemplate="emptymessage">
<tr>
<td colspan="7">No customers found.</td>
2021-12-09 14:24:42 +00:00
</tr>
</ng-template>
2021-12-21 12:15:22 +00:00
<ng-template pTemplate="loadingbody">
<tr>
<td colspan="7">Loading customers data. Please wait.</td>
</tr>
</ng-template>
</p-table>
2021-12-09 14:24:42 +00:00
</div>
</div>
<div class="col-12">
<div class="card">
<h5>Frozen Columns</h5>
<p-toggleButton [(ngModel)]="idFrozen" [onIcon]="'pi pi-lock'" offIcon="pi pi-lock-open" [onLabel]="'Unfreeze Id'" offLabel="Freeze Id" [style]="{'width': '12rem'}"></p-toggleButton>
2021-12-21 08:18:31 +00:00
<p-table [value]="customers3" scrollDirection="both" [scrollable]="true" scrollHeight="400px" styleClass="mt-3" responsiveLayout="scroll">
<ng-template pTemplate="header">
<tr>
<th style="width:200px" pFrozenColumn>Name</th>
<th style="width:200px" alignFrozen="left" pFrozenColumn [frozen]="idFrozen">Id</th>
<th style="width:200px">Country</th>
<th style="width:200px">Date</th>
<th style="width:200px">Company</th>
<th style="width:200px">Status</th>
<th style="width:200px">Activity</th>
<th style="width:200px">Representative</th>
2021-12-21 08:18:31 +00:00
<th style="width:200px" pFrozenColumn alignFrozen="right">Balance</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-customer>
<tr>
<td style="width:200px" pFrozenColumn>{{customer.name}}</td>
<td style="width:200px" alignFrozen="left" pFrozenColumn [frozen]="idFrozen">{{customer.id}}</td>
2021-12-21 12:27:33 +00:00
<td style="width:200px">
<img src="assets/demo/flags/flag_placeholder.png" [class]="'flag flag-' + customer.country.code" width="30">
<span class="image-text ml-2">{{customer.country.name}}</span>
</td>
<td style="width:200px">{{customer.date}}</td>
<td style="width:200px">{{customer.company}}</td>
2021-12-21 12:27:33 +00:00
<td style="width:200px">
<span [class]="'customer-badge status-' + customer.status">{{customer.status}}</span>
</td>
<td style="width:200px">{{customer.activity}}</td>
2021-12-21 12:28:42 +00:00
<td style="width:200px">
<img [alt]="customer.representative.name" src="assets/demo/images/avatar/{{customer.representative.image}}" width="32" style="vertical-align: middle"/>
<span class="image-text ml-2">{{customer.representative.name}}</span>
</td>
2021-12-21 08:18:31 +00:00
<td style="width:200px" pFrozenColumn alignFrozen="right">{{formatCurrency(customer.balance)}}</td>
</tr>
</ng-template>
</p-table>
</div>
</div>
2021-12-09 14:24:42 +00:00
<div class="col-12">
<div class="card">
<h5>Row Expand</h5>
<p-toast></p-toast>
2021-12-21 12:15:22 +00:00
<p-table [value]="products" dataKey="name" [expandedRowKeys]="expandedRows" responsiveLayout="scroll">
2021-12-09 14:24:42 +00:00
<ng-template pTemplate="caption">
<button pButton icon="pi pi-fw {{isExpanded ? 'pi-minus' : 'pi-plus'}}" label="{{isExpanded ? 'Collapse All' : 'Expand All'}}" (click)="expandAll()"></button>
2021-12-09 14:24:42 +00:00
<div class="flex table-header">
</div>
</ng-template>
<ng-template pTemplate="header">
<tr>
<th style="width: 3rem"></th>
<th pSortableColumn="name">Name <p-sortIcon field="name"></p-sortIcon></th>
<th>Image</th>
<th pSortableColumn="price">Price <p-sortIcon field="price"></p-sortIcon></th>
<th pSortableColumn="category">Category <p-sortIcon field="category"></p-sortIcon></th>
<th pSortableColumn="rating">Reviews <p-sortIcon field="rating"></p-sortIcon></th>
<th pSortableColumn="inventoryStatus">Status <p-sortIcon field="inventoryStatus"></p-sortIcon></th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-product let-expanded="expanded">
<tr>
<td>
<button type="button" pButton pRipple [pRowToggler]="product" class="p-button-text p-button-rounded p-button-plain" [icon]="expanded ? 'pi pi-chevron-down' : 'pi pi-chevron-right'"></button>
</td>
2021-12-21 12:57:32 +00:00
<td style="min-width: 12rem;">{{product.name}}</td>
2021-12-21 12:15:22 +00:00
<td><img [src]="'assets/demo/images/product/' + product.image" [alt]="product.name" width="100" class="shadow-4" /></td>
2021-12-21 12:57:32 +00:00
<td style="min-width: 8rem;">{{product.price | currency:'USD'}}</td>
<td style="min-width: 10rem;">{{product.category}}</td>
<td style="min-width: 10rem;"><p-rating [ngModel]="product.rating" [readonly]="true" [cancel]="false"></p-rating></td>
2021-12-21 12:15:22 +00:00
<td><span [class]="'product-badge status-' + product.inventoryStatus.toLowerCase()">{{product.inventoryStatus}}</span></td>
2021-12-09 14:24:42 +00:00
</tr>
</ng-template>
<ng-template pTemplate="rowexpansion" let-product>
<tr>
<td colspan="7">
<div class="p-3">
2021-12-21 12:15:22 +00:00
<p-table [value]="product.orders" dataKey="id" responsiveLayout="scroll">
2021-12-09 14:24:42 +00:00
<ng-template pTemplate="header">
<tr>
<th pSortableColumn="id">Id <p-sortIcon field="price"></p-sortIcon></th>
<th pSortableColumn="customer">Customer <p-sortIcon field="customer"></p-sortIcon></th>
<th pSortableColumn="date">Date <p-sortIcon field="date"></p-sortIcon></th>
<th pSortableColumn="amount">Amount <p-sortIcon field="amount"></p-sortIcon></th>
<th pSortableColumn="stats">Status <p-sortIcon field="status"></p-sortIcon></th>
<th style="width: 4rem"></th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-order>
<tr>
2021-12-21 12:15:22 +00:00
<td>{{order.id}}</td>
<td>{{order.customer}}</td>
<td>{{order.date}}</td>
<td>{{order.amount | currency:'USD'}}</td>
<td><span [class]="'order-badge order-' + order.status.toLowerCase()">{{order.status}}</span></td>
2021-12-09 14:24:42 +00:00
<td><p-button type="button" icon="pi pi-search"></p-button></td>
</tr>
</ng-template>
<ng-template pTemplate="emptymessage">
<tr>
<td colspan="6">There are no order for this product yet.</td>
</tr>
</ng-template>
</p-table>
</div>
</td>
</tr>
</ng-template>
</p-table>
</div>
</div>
2021-12-09 14:24:42 +00:00
<div class="col-12">
<div class="card">
<h5>Subheader Grouping</h5>
2021-12-21 12:15:22 +00:00
<p-table [value]="customers3" rowGroupMode="subheader" groupRowsBy="representative.name" sortField="representative.name" sortMode="single" (onSort)="onSort()" responsiveLayout="scroll" [scrollable]="true" scrollHeight="400px">
<ng-template pTemplate="header">
<tr>
<th>Name</th>
<th>Country</th>
<th>Company</th>
<th>Status</th>
<th>Date</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-customer let-rowIndex="rowIndex">
2021-12-21 08:25:11 +00:00
<tr pRowGroupHeader *ngIf="rowGroupMetadata[customer.representative.name].index === rowIndex">
<td colspan="5" style="min-width: 200px;">
<img [alt]="customer.representative.name" src="assets/demo/images/avatar/{{customer.representative.image}}" width="32" style="vertical-align: middle" />
2021-12-21 10:20:09 +00:00
<span class="font-bold ml-2">{{customer.representative.name}}</span>
</td>
</tr>
<tr>
2021-12-21 12:57:32 +00:00
<td style="min-width: 200px;">
{{customer.name}}
</td>
2021-12-21 12:57:32 +00:00
<td style="min-width: 200px;">
<img src="assets/demo/flags/flag_placeholder.png" [class]="'flag flag-' + customer.country.code" width="30">
<span class="image-text" style="margin-left: .5em">{{customer.country.name}}</span>
</td>
2021-12-21 12:57:32 +00:00
<td style="min-width: 200px;">
{{customer.company}}
</td>
2021-12-21 12:57:32 +00:00
<td style="min-width: 200px;">
<span [class]="'customer-badge status-' + customer.status">{{customer.status}}</span>
</td>
2021-12-21 12:57:32 +00:00
<td style="min-width: 200px;">
{{customer.date}}
</td>
</tr>
</ng-template>
</p-table>
</div>
2021-12-09 14:24:42 +00:00
</div>
</div>