Skip to content

Commit d36578b

Browse files
committed
refactor(ngx-print-demo): update layout and enhance button functionality with ViewPrimaryButtonDirective
1 parent cf6ec81 commit d36578b

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
<div class="m-2 container">
1+
<div class="m-2 container-fluid">
22
<div class="row">
33
<div class="col-12">
44
<h2 class="text-center">NGX Print Directive Demo</h2>
55
<p class="text-center">This is a demo of the NGX Print Directive. It is used to print the table to a PDF
66
file.</p>
77
<div class="text-center">
88
<button [hideMatTablePaginator]="true" [isMatTable]="true" [matTableDataSource]="dataSource"
9-
[paginator]="paginator" [useExistingCss]="true" class="pdf-export-button form-col-2" mat-raised-button
10-
ngxPrint paginatorId="mat-paginator" printSectionId="print_id" color="primary" type="button">
9+
[paginator]="paginator" [useExistingCss]="true" class="pdf-export-button form-col-2" viewPrimaryButton
10+
[icon]="'print'" mat-raised-button ngxPrint paginatorId="mat-paginator" printSectionId="print_id"
11+
type="button">
1112
Export to PDF
1213
</button>
1314
</div>
1415
</div>
1516
</div>
1617

18+
<!-- Generate Mat Table with sorting and pagination -->
19+
<table mat-table class="m-5" [dataSource]="dataSource" matSort matSortActive="name" matSortDirection="asc"
20+
id="print_id">
21+
<ng-container matColumnDef="name">
22+
<mat-header-cell *matHeaderCellDef mat-sort-header> Name </mat-header-cell>
23+
<mat-cell *matCellDef="let element"> {{ element.name }} </mat-cell>
24+
</ng-container>
25+
<ng-container matColumnDef="email">
26+
<mat-header-cell *matHeaderCellDef mat-sort-header> Email </mat-header-cell>
27+
<mat-cell *matCellDef="let element"> {{ element.email }} </mat-cell>
28+
</ng-container>
29+
<ng-container matColumnDef="phone">
30+
<mat-header-cell *matHeaderCellDef mat-sort-header> Phone </mat-header-cell>
31+
<mat-cell *matCellDef="let element"> {{ element.phone }} </mat-cell>
32+
</ng-container>
33+
<ng-container matColumnDef="website">
34+
<mat-header-cell *matHeaderCellDef mat-sort-header> Website </mat-header-cell>
35+
<mat-cell *matCellDef="let element"> {{ element.website }} </mat-cell>
36+
</ng-container>
37+
<mat-header-row *matHeaderRowDef="['name', 'email', 'phone', 'website']"></mat-header-row>
38+
<mat-row *matRowDef="let row; columns: ['name', 'email', 'phone', 'website']"></mat-row>
39+
</table>
40+
<mat-paginator id="mat-paginator" [pageSize]="5" [pageSizeOptions]="[5,10, 20, 50, 100]"
41+
[length]="result.value()?.length ?? 0"></mat-paginator>
1742
</div>
18-
<!-- Generate Mat Table with sorting and pagination -->
19-
<table mat-table class="m-5" [dataSource]="dataSource" matSort matSortActive="name" matSortDirection="asc"
20-
id="print_id">
21-
<ng-container matColumnDef="name">
22-
<mat-header-cell *matHeaderCellDef mat-sort-header> Name </mat-header-cell>
23-
<mat-cell *matCellDef="let element"> {{ element.name }} </mat-cell>
24-
</ng-container>
25-
<ng-container matColumnDef="email">
26-
<mat-header-cell *matHeaderCellDef mat-sort-header> Email </mat-header-cell>
27-
<mat-cell *matCellDef="let element"> {{ element.email }} </mat-cell>
28-
</ng-container>
29-
<ng-container matColumnDef="phone">
30-
<mat-header-cell *matHeaderCellDef mat-sort-header> Phone </mat-header-cell>
31-
<mat-cell *matCellDef="let element"> {{ element.phone }} </mat-cell>
32-
</ng-container>
33-
<ng-container matColumnDef="website">
34-
<mat-header-cell *matHeaderCellDef mat-sort-header> Website </mat-header-cell>
35-
<mat-cell *matCellDef="let element"> {{ element.website }} </mat-cell>
36-
</ng-container>
37-
<mat-header-row *matHeaderRowDef="['name', 'email', 'phone', 'website']"></mat-header-row>
38-
<mat-row *matRowDef="let row; columns: ['name', 'email', 'phone', 'website']"></mat-row>
39-
</table>
40-
<mat-paginator id="mat-paginator" [pageSize]="5" [pageSizeOptions]="[5,10, 20, 50, 100]"
41-
[length]="result.value()?.length ?? 0"></mat-paginator>
42-
<hr />

projects/ng-kit-demo/src/app/ngx-print-demo/ngx-print-demo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { MatButtonModule } from '@angular/material/button';
44
import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
55
import { MatSort, MatSortModule } from '@angular/material/sort';
66
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
7-
import { NgxPrintDirective } from '@js-smart/ng-kit';
7+
import { NgxPrintDirective, ViewPrimaryButtonDirective } from '@js-smart/ng-kit';
88

99
interface User {
1010
id: number;
@@ -16,7 +16,7 @@ interface User {
1616

1717
@Component({
1818
selector: 'ngx-print-demo',
19-
imports: [MatTableModule, MatPaginatorModule, MatSortModule, NgxPrintDirective, MatButtonModule],
19+
imports: [MatTableModule, MatPaginatorModule, MatSortModule, NgxPrintDirective, MatButtonModule, ViewPrimaryButtonDirective],
2020
templateUrl: './ngx-print-demo.html',
2121
styles: [``],
2222
changeDetection: ChangeDetectionStrategy.OnPush,

0 commit comments

Comments
 (0)