The data table fails to display updated information from the data source

After updating the data-array (FileDto), I am unable to see any changes reflected in the Datatable.

I have tested outputting the data using ngFor, and it works perfectly fine.

Here is the HTML code:

<ngx-datatable
  class="material striped"
  [rows]="fileDtos"
  [columnMode]="'force'"
  [rowHeight]="'auto'"
  [messages]="gridMessages"
>
    <ngx-datatable-column name="name" >
        <ng-template let-column="column" ngx-datatable-header-template>
          <strong>{{ 'FILES.NAME' | translate}}</strong>
        </ng-template>
    </ngx-datatable-column>
</ngx-datatable>

Typescript file:

loadFiles(): void {
    this._fileService.getFiles(this.auftragId, false).subscribe(files => {
      this.fileDtos = files;
      this._fileService.getExcelFiles(this.auftragId).subscribe(filesexcel => {
        if ( filesexcel) {
          filesexcel.forEach(item => {
            this.fileDtos.push(item);
          });
        }
      });
    });
}

Data object:

export class FileDto {
    name: string;
    iconUrl: string;
    extension: string;
    created: Date | string;
    modified: Date | string;
}

Despite not receiving any error messages, the Datatable does not display any data. Any insights on why this might be happening?

Sample data:

{name: "Filename1.xlsm", iconUrl: null, extension: "", created: "2019-03-12T13:37:25.973", modified: "0001-01-01T00:00:00"}
{name: "Filename2.xlsm", iconUrl: null, extension: "", created: "2019-03-12T12:13:53.847", modified: "0001-01-01T00:00:00"}
{name: "Filename3.xlsm", iconUrl: null, extension: "", created: "2019-03-12T13:37:25.973", modified: "0001-01-01T00:00:00"}

Answer №1

Big thanks to @sgrillon for pointing out that nesting subscribe calls is not recommended. Now everything is working perfectly.

Here's the approach I took using forkJoin:

forkJoin(
      this._fileService.retrieveFiles(this.auftragId, false), this._fileService.getExcelFiles(this.auftragId)
    ).subscribe((files) => {
      this.fileDtos = files[0].concat(files[1]);
    });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Avoiding page refresh while utilizing the ng5-slider component in Angular

I am currently working with an ng5-slider that has a customizable range from 0 to 1000. However, I have encountered an issue when adjusting the slider at the bottom of the page - it refreshes and automatically takes me back to the top of the page. I would ...

I'm having trouble getting my nav-tab to function properly in Bootstrap 4 when used with Angular 4. Can

I have been attempting to utilize Bootstrap 4 tabs with Angular 4 with the expectation that it would resemble and function similar to this example enter link description here However, my page is displaying like this. https://i.sstatic.net/dymNH.png Here ...

Error: The data received from the Axios GET request cannot be assigned to the parameter type of SetState

Currently I am in the process of building my initial TypeScript application after transitioning from a JavaScript background. While I am still adjusting to the concept of declaring types, there is a specific issue I am encountering at the moment. The sni ...

Guidelines for incorporating Dropdown menus in a Multi-level Carousel themed SideNav using Angular 5 Material

https://i.sstatic.net/cbmuA.gif Hey there, World! I've been working on a sidenav with tabs that has the perfect transition effect I was looking for. Now, I want to add functionality so that when users click on "Option 1, Option 2 or Option 3", the tab ...

Angular - Issue with Function Observable<number> in Development

Currently, I'm working on writing TypeScript code for a component. Within this TypeScript class, I have created a function that is meant to return a number representing the length of an array. My goal is to have this function work like an Observable. ...

Learn the process of automatically copying SMS message codes to input fields in Angular17

After receiving the first answer, I made some changes to the code. However, when testing it with Angular, I encountered several errors. How can I resolve these issues? TS: async otpRequest() { if ('OTPCredential' in window) { const ab ...

Avoid duplication of values in Angular4 when using *ngFor

Looking for assistance in updating an AngularJS project to Angular4. I have a JSON rest endpoint that returns a list of activities sorted by date and time. In AngularJS, I utilized ng-repeat to iterate through the data and ng-show to prevent duplicate entr ...

Issue at 13th instance: TypeScript encountering a problem while retrieving data within an asynchronous component

CLICK HERE FOR ERROR IMAGE export const Filter = async (): Promise<JSX.Element> => { const { data: categories } = await api.get('/categories/') return ( <div className='w-full h-full relative'> <Containe ...

What causes the Babel JSON configuration error to appear in my project?

I'm currently working on a React website, utilizing TSX instead of JSX. In my setup, I am using webpack and Babel. However, I have encountered an error while running the webpack-dev-server. ERROR in ./src/index.tsx Module build failed (from ./node_mo ...

Determining a value that increases to yield a fresh sum

I'm currently developing a character generator that determines your score based on the experience points you allocate to it. The scoring system is such that 1 XP gives you a score of 1, 3 XP gives you a score of 2, 6 XP gives you a score of 3, 10 XP g ...

TypeORM reporting duplication error when bulk saving data instead of detecting and ignoring existing records or updating their values

According to the documentation provided by TypeOrm Framework, the Repository.save function is supposed to save/insert new values and ignore/update existing ones. However, I am currently experiencing an issue where it is throwing a duplication error for an ...

What distinguishes injecting a provider in Angular2's @Component versus @Module?

When working with Angular2, it is possible to specify the providers in either a @Component element or in a @NgModule element. For example: @Component({ selector: 'app-home', templateUrl: './home.component.html', styleUrls: [&apos ...

Exploring the capabilities of Angular2 in conjunction with Symfony3's FOSOAuthServerBundle for secure

Trying to integrate my angular2 frontend app with a symfony backend. Currently using FOSOAuthServerBundle (https://github.com/FriendsOfSymfony/FOSOAuthServerBundle) for authorization, but struggling to fully grasp the implementation process. Experiment ...

Creating a structured state declaration in NGXS for optimal organization

Currently, I'm delving into the world of NGXS alongside the Emitters plugin within Angular, and I find myself struggling to grasp how to organize my state files effectively. So far, I've managed to define a basic .state file in the following man ...

Challenge with sharing an array from a different component in Angular using @Input()

Recently, I started learning Angular and decided to create a basic blog application. While trying to retrieve a property from another component using the @Input() decorator, I encountered an issue specifically related to arrays. In a post-list-item compone ...

failure of pipe during search for art gallery information

Hi, I've created a filter pipe to search for imagenames and imageids among all my images. However, it seems to only find matches in the first image. There seems to be something wrong with my code. This is my FilterPipe class in filter.pipe.ts where I ...

Using Angular 6's httpClient to securely post data with credentials

I am currently working with a piece of code that is responsible for posting data in order to create a new data record. This code resides within a service: Take a look at the snippet below: import { Injectable } from '@angular/core'; import { H ...

Developing a dynamic web application using Asp.Net Core integrated with React and material

After setting up an Asp.Net Core project using the react template, I decided to incorporate material-ui by following the steps outlined on this page. However, encountered some dependency issues along the way. To resolve them, I had to update the react and ...

Is there a way to get this reducer function to work within a TypeScript class?

For the first advent of code challenge this year, I decided to experiment with reducers. The following code worked perfectly: export default class CalorieCounter { public static calculateMaxInventoryValue(elfInventories: number[][]): number { const s ...

Exploring Nuxt's Getters with vuex-class for seamless data retrieval

Currently, I am in the process of developing an application using Nuxt and experimenting with vuex for the first time. Despite following numerous tutorials to set it up, I'm encountering difficulties accessing the store and suspect that the issues may ...