My current dilemma involves a component named user-table-list
, which essentially represents a table with entries corresponding to various users.
Within this setup, there exists another component called table-list
, responsible for defining the structure and behavior of tables for multiple components (including user-table-list
). The HTML code for user-table-list
looks like this:
<app-table-list #table [tableConfiguration]="usersTableConfiguration"></app-table-list>
On the other hand, the HTML code for table-list
contains the layout details such as columns, headers, etc. The configurations specific to each individual table, including data loading and column names, are defined in the corresponding .ts file.
In the header section, there is a button for adding new entries to the table, whether they are users, clients, or any other entity. The event handling and database operations take place within table-list.component.ts
, where different actions are executed based on the type of table the event originates from. Here's an example snippet:
createNewButtonClicked(tableType: string) {
const dialogConfig = new MatDialogConfig();
dialogConfig.width = '60%';
dialogConfig.autoFocus = true;
switch (tableType) {
case 'clients': {
this.dialog.open(ClientDialogComponent, dialogConfig);
break;
}
case 'projects': {
this.dialog.open(ProjectDialogComponent, dialogConfig);
break;
}
case 'users':{
this.dialog.open(UserDialogComponent, dialogConfig);
break;
}
}
}
When a new client/project/user is added through these dialogs, I aim to refresh the list by triggering a method that retrieves data from the database. However, the challenge lies in finding a way to trigger this refresh externally without resorting to page reloads. Attempts to achieve this directly in the dialog or table-list components have failed due to circular references. Even creating an external service for this task results in the same issue.
I'm currently at a loss for solutions; how can this desired functionality be implemented without modifying the existing application architecture?