Issue with Angular table display cell overloading(produces excessive rendering of cells)

In my project, I am working with 3 arrays of data - DATA_CENT, DATA_NORTH, and DATA_WEST. Each of these arrays contains another array called data, which I need to extract and display in a table format.

For each new column, I create a new table and then populate it with the extracted data.

<table *ngFor="let elem of COLUMN_NAMES">
    <thead>
        <tr>
            <th colspan="4" class="top">{{elem}}</th>
        </tr>
        <tr>
            <th class="top-1">all</th>
            <th class="top-1">done</th>
            <th class="top-1">ctrl</th>
            <th class="top-1">rjct</th>
        </tr>
    </thead>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tbody *ngIf="showcent">
        <tr *ngFor="let comp of elem.data">
            // Render DATA_CENT.data information here
            <td>{{comp.all}}</td>
            <td>{{comp.done}}</td>
            <td>{{comp.ctrl}}</td>
            <td>{{comp.rjct}}</td>
        </tr>
    </tbody>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tbody *ngIf="shownorth">
        <tr *ngFor="let comp of elem1.data">
            // Display DATA_NORTH information
            <td>{{comp.all}}</td>
            <td>{{comp.done}}</td>
            <td>{{comp.ctrl}}</td>
            <td>{{comp.rjct}}</td>
        </tr>
    </tbody>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tbody *ngIf="showwest">
        <ng-container>
            <tr *ngFor="let comp of elem1.data">
                // Display DATA_WEST information
                <td>{{comp.all}}</td>
                <td>{{comp.done}}</td>
                <td>{{comp.ctrl}}</td>
                <td>{{comp.rjct}}</td>
            </tr>
        </ng-container>
    </tbody>
</table>

I am facing challenges in rendering the table correctly due to loop placement issues. Sometimes the cells are not fitting properly in the table structure.

You can view the table format here: https://i.sstatic.net/fqRUu.png

PS: The first 3 cells in the first column are buttons which control the folding/unfolding of associated data.

If you need more information, you can visit the project's GitHub page: https://github.com/kulaska/Table-app/tree/table_el_toggle_branch

Answer №1

It seems like the issue you are facing is a result of not properly iterating through the data array.

Instead of:

<td>{{comp.data.all}}</td>

You should do:

<td>
    <tr *ngFor="let data of comp.data">
        <td>{{data.all}}</td>
    </tr>
</td>

Ensure that you loop through the data array to resolve the issue.

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

Every instance of 'WeakMap' must include the same type parameters

While developing an Ionic App, I encountered a strange issue. Everything was running smoothly until I cloned the source code to a different machine, which resulted in an error that is displayed in the attached image. Even though there are no compilation e ...

What is the best method to convert a variable array into a string array using jQuery in the context

I've been working with this jQuery code snippet: function extractParameter() { var values = []; $("input[name='SelectedServiceTypes']:checked").each(function (i) { values.push($(this).val()); }); if (values.length == ...

What could be the reason for a code running successfully in node but not in the REPL environment?

This is the current script I'm working with: const lib = require('./lib.js'); const fs = require('fs'); const graph = fs.readFileSync('../js-working-dir/add_graph.pb', 'utf8'); const sess = new lib.Session(gr ...

Obtaining the data object from a tag in Internet Explorer 8

When using Chrome, the following line of code provides a useful result: $('[data-buyername]').data() It will retrieve the value associated with the tag data-buyername='somethingArbitrary' However, in IE8, the .data() function does no ...

Loading events for a fullCalendar in node.js using the jade library

I successfully integrated fullCalendar into my nodeJS application using jade and Express, and I have managed to load the calendar. Within the jade file, I pass an array containing events information. How can I display these events on the calendar within th ...

Clickable regions in Internet Explorer 7 that lack a specific width

Is there a way to make the clickable area of links always stretch to the parents container when the parent container does not have a fixed width? For example, check out this JSFiddle. In Firefox, the link stretches with the text and the li tag, but in IE ...

instructions for executing this javascript within the <p> tag

This is the code I have written : <p onload=javascript:alert('sss')>www</p> Unfortunately, the code does not alert 'sss', Can someone please tell me what's wrong with my code? Thank you ...

What mistake am I making with arrays?

My understanding of JavaScript and Node.JS is still developing, so I'm puzzled as to why I'm receiving NaN when using this expression: var aUsersBetted = {}; aUsersBetted['1337'] += 200000; logger.debug(aUsersBetted['1337']); ...

Uncovering the jsPlumb link between a pair of identifiers

Could someone help me understand how to disconnect two HTML elements that are connected? I have the IDs of both elements, but I'm not sure how to locate their connection in the jsPlumb instance. Any tips on finding the connection between two IDs? ...

Access WordNet using JavaScript

Currently developing a web application that involves NLP tasks. In my past projects, I have used the JWNL library in Java which has always served me well. I am curious to know if you have any advice on the most effective approach for querying the WordNet ...

Every time I try to utilize "useCallback," it results in a TypeError error popping up

I am struggling with an issue related to a const experience that involves creating 6 experiences with their respective popovers. I have been instructed to use useCallback, but every time I attempt to do so, I encounter an error message. This relates to my ...

Smoothly animate a Three.js object in response to an event without changing its current position

I need assistance with slowing down the rotation animation of a cube when a mouse hovers over it and making it continue smoothly on mouse leave. The current issue I'm facing is that when the mouse enters the cube, the rotation slows down but abruptly ...

Problems Arising with Javascript Animation Functionality

I've created a script for an interactive "reel" that moves up or down when clicking on specific arrow buttons. However, I'm encountering two issues: 1) The up arrow causes it to move downward, while the down arrow moves it upward. 2) After exe ...

Deactivate checkbox based on dropdown selection

I'm facing an issue where I need to disable a checkbox when a certain option is selected from a dropdown inside a datatable in my xhtml file. The dropdown has options like L, C, UV, and more, and when "L" is chosen, the checkbox should be disabled. B ...

Rearrange the position of the divs in every other container

Assume that I have the following HTML structure: <div class="article"> <div class="article_img"></div> <div class="article_preview"></div> </div> Both article_img and article_preview elements have a defined width and ...

Creating a .env file using Vanilla JavaScript to securely store and conceal tokens

I am currently working on a vanilla JavaScript project. Within the app.js file, I am making an API call to retrieve specific values. Initially, I tested the API using Postman by including all the necessary headers there and then implemented the code in my ...

What could be the reason for the malfunctioning of this JavaScript code?

Regarding the content found in this post: How to display a loading image while the actual image is downloading. I have implemented the following code snippet, however, I am facing an issue where the #loader_img element does not hide. Additionally, I would ...

What is the best way to insert a record into the rth column of the nth row in a table

In the table I'm working with, there are 6 columns and only 5 of them have data filled in. The last column is currently empty for all rows. I am now trying to populate the last column of each row with some data. Can someone guide me on how to use a f ...

Modifying an @Input element within a component does not result in any changes being reflected in the parent component

Here is the scenario with my component: @Component({ selector: 'child' }) export class ChildComponent { @Input() childObject: ChildObject; changeObject(newObject: ChildObject){ childObject = newObject; } } After calling ...

Utilizing a filter within the ng-model directive

I have a question about using a filter with an h3 element. Here is the code snippet: {{ event.date | date:'dd-MM-yyyy' }} It's working perfectly fine and Angular is formatting the date as expected. However, when I try to use the same filte ...