TABLEHTML-SCSS-TS
TABLEHTML-SCSS-TS
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body style="height:123vh">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<div class="table-container">
</div>
</body>
</html>
</body>
</html>
SCSS:
.container {
// display: grid;
grid-template-columns: 1fr;
grid-template-rows: 1fr;
gap: 0px 0px;
grid-template-areas:
". advance ."
". . ."
". . .";
}
.body{
min-height: 75vh ;
height: auto ;
margin: 0;
font-family: Roboto, "Helvetica Neue", sans-serif;
// overflow-y: auto;
}
.customerProfile{
border-style: solid;
border-color: #428bca;
}
.panel-heading {
padding: 10px 15px;
border-bottom: 1px solid transparent;
border-top-right-radius: 1px;
border-top-left-radius: 1px;
}
.panel-title {
margin-top: 0;
margin-bottom: 0;
font-size: 15px;
color: inherit;
}
.pull-right {
float: right !important;
}
.backgroundcolor{
background-color: #428bca;
}
.container {
background-color: white;
height:50vh;
margin-top: 36px;
#button-gap {
margin-right: 5px;
}
.mat-elevation-z8{
overflow-x: scroll;
}
.clickable-link {
cursor: pointer;
}
.table-container {
height: 60vh; /* Set a fixed height of 50% of the viewport height */
overflow: auto; /* Enable vertical scrolling if content overflows */
overflow-x: auto;
}
.checkbox{
background-color: #fff;
}
.table-container {
height: 483px; /* Set the maximum height for the table container */
overflow-y: auto; /* Enable vertical scrolling */
background: white;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 8px;
border: 1px solid #ddd;
text-align: left;
}
th {
background-color: #f2f2f2;
position: sticky;
top: 0;
}
.table-header {
display: flex;
align-items: center;
justify-content: center;
}
TS CODE:
import { HttpClient } from '@angular/common/http';
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { environment } from 'src/Environments/environment';
import { CoreService } from
'src/app/Services/CustomerVSEmployee/Core/core.service';
import { LoginService } from 'src/app/Services/Login/login.service';
import { EditVendorComponent } from '../edit-vendor/edit-vendor.component';
import { MatDialog } from '@angular/material/dialog';
import { VendorService } from 'src/app/Services/Vendor/vendor.service';
import { UpdatevendorComponent } from '../updatevendor/updatevendor.component';
import { SpinnerService } from '../../Spinner/spinner.service';
import { catchError } from 'rxjs';
import Swal from 'sweetalert2/src/sweetalert2.js'
@Component({
selector: 'app-vendor',
templateUrl: './vendor.component.html',
styleUrls: ['./vendor.component.scss']
})
export class VendorComponent implements OnInit {
ngOnInit(): void {
this.fetchtableData();
}
constructor(private spinnerService:SpinnerService, private
VendorService:VendorService, private http: HttpClient, private loginservice:
LoginService, private coreservice: CoreService, private _dialog: MatDialog) { }
dataSource: MatTableDataSource<any>;
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
displayedColumns: string[] = ['VendorName', 'InvoiceNumber', 'InvoiceDate',
'InvoiceValue', 'PendingAmount', 'AmountPaid', 'Action'];
btnAccountEEdit(id: string) {
// Implement your edit logic here
}
fetchtableData() {
this.spinnerService.requestStarted();
this.http.get<any>(environment.apiURL +
`ITAsset/nGetVendorData`).pipe(catchError((error) => {
this.spinnerService.requestEnded();
return Swal.fire('Alert!', 'An error occurred while processing your request',
'error');
})).subscribe({
next:(data) => {
this.spinnerService.requestEnded();
this.dataSource = new MatTableDataSource(data.vendorGDetailList);
this.dataSource.paginator = this.paginator;
// this.dataSource.sort = this.sort;
},
error: (err: any) => {
this.spinnerService.resetSpinner();
}
});
}
openvendor(){
const dialogRef = this._dialog.open(EditVendorComponent);
dialogRef.afterClosed().subscribe({
next: (val) => {
if (val) {
this.fetchtableData();
}
},
});
}
openEditForm(data:any){
const dialogRef = this._dialog.open(UpdatevendorComponent, {
data:{
type:"edit",
data:data
},
});
dialogRef.afterClosed().subscribe({
next: (val) => {
if (val) {
this.fetchtableData();
}
}
});
}
}