I see the issue now. There are a few problems with your code:
1. Mismatched Data Types
Your dataSource is declared as MatTableDataSource<ChemicalSubstanceLocationModel>(), but you're assigning data of type ChemicalSubstanceModel[] to it (processedData).
const processedData = JSON.parse(JSON.stringify(dataRes.pageData)); // ChemicalSubstanceModel[]
this.dataSource.data = processedData; // Assigning to MatTableDataSource<ChemicalSubstanceLocationModel>
Fix: Update the dataSource declaration to match the actual data type:
dataSource = new MatTableDataSource<ChemicalSubstanceModel>(); // Not ChemicalSubstanceLocationModel
2. Missing matColumnDef bindings in cells
Your mat-cell elements are empty. You need to bind the actual data properties to display them. For example:
<ng-container [matColumnDef]="getConstantColumnName.NAME_BOX_COLUMN_NAME">
<mat-header-cell mat-header-cell *matHeaderCellDef>
{{('COMMON.NAME' | translate)}}
</mat-header-cell>
<mat-cell *matCellDef="let element">
{{ element.name }} <!-- Bind the 'name' property of ChemicalSubstanceModel -->
</mat-cell>
</ng-container>
3. mat-header-row should be outside the empty ng-container
Move the mat-header-row and mat-row definitions outside any ng-container. The corrected structure should be:
<mat-table class="pure-gap-table" qms-table [dataSource]="dataSource">
<!-- Column definitions -->
<ng-container [matColumnDef]="getConstantColumnName.CHECK_BOX_COLUMN_NAME">
<!-- ... -->
</ng-container>
<ng-container [matColumnDef]="getConstantColumnName.NAME_BOX_COLUMN_NAME">
<!-- ... -->
</ng-container>
<!-- Row definitions -->
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row qms-table-row *matRowDef="let row; columns: displayedColumns;" (click)="onClickTableRow(row)"></mat-row>
</mat-table>
4. Verify processedData is not empty
Add a console log to ensure processedData has data:
const processedData = JSON.parse(JSON.stringify(dataRes.pageData));
console.log('Processed Data:', processedData); // Check if it's not empty
5. Optional: Trigger change detection manually