Hi
Data has 2 records but it is not displaying in table
Crud Application
Filter
ID
{{row.id}}
First Name
{{row.empName}}%
Contact No
{{row.empContactNo}}
Email
{{row.empEmail}}
Action
No data matching the filter "{{input.value}}"
export class LayoutComponent implements OnInit {
displayedColumns: string[] = ['id', 'empName', 'empContactNo', 'empEmail','action'];
dataSource!: MatTableDataSource;
@ViewChild(MatPaginator) paginator!: MatPaginator;
@ViewChild(MatSort) sort!: MatSort;
constructor(private _dialog:MatDialog){}
openAddEditForm(){
this._dialog.open(EmpAddEditComponent)
}
ngOnInit(): void {
this.getallEmployee();
}
getallEmployee() {
this.----.get('onlinetestapi.gerasim.in/api/TeamSync/GetAllEmployee').subscribe((result: any)=>{
this.dataSource = new MatTableDataSource(result);
debugger;
// this.dataSource.sort = this.sort;
// this.dataSource.paginator = this.paginator;
})
}
applyFilter(event: Event) {
const filterValue = (event.target as HTMLInputElement).value;
this.dataSource.filter = filterValue.trim().toLowerCase();
if (this.dataSource.paginator) {
this.dataSource.paginator.firstPage();
}
}
}
Thanks
Jobin SPosted Jun 4, 2024, 2:47 PM
Hi Ramco,
try this changes and also Dom Side some changes
export class LayoutComponent implements OnInit {;
displayedColumns: string[] = ['id', 'empName', 'empContactNo', 'empEmail','action'];
dataSource!: MatTableDataSource
@ViewChild(MatPaginator) paginator!: MatPaginator;
@ViewChild(MatSort) sort!: MatSort;
constructor(private _dialog:MatDialog){}
openAddEditForm(){
this._dialog.open(EmpAddEditComponent)
}
ngOnInit(): void {
this.getallEmployee();
}
getallEmployee() {
this.----.get('onlinetestapi.gerasim.in/api/TeamSync/GetAllEmployee').subscribe((result: any)=>{
this.dataSource = new MatTableDataSource(result.data);
debugger;
// this.dataSource.sort = this.sort;
// this.dataSource.paginator = this.paginator;
})
}
applyFilter(event: Event) {
const filterValue = (event.target as HTMLInputElement).value;
this.dataSource.filter = filterValue.trim().toLowerCase();
if (this.dataSource.paginator) {
this.dataSource.paginator.firstPage();
}
}
}