Calculate the total of each column in ng-table using AngularJS framework

Currently, I am utilizing angular/ng-table to display numerical data in a tabular format. However, one issue I am facing is how to add a row at the bottom of my table that displays the sum of all values in each column. While I can compute this sum on the server side and then present it on the UI, I am unsure if there is a way to accomplish this using ng-table/ng-grid directly. Any assistance on this matter would be greatly appreciated.

Thank you.

Answer №1

Is this the format you had in mind?

<table ng:init="data={items:[{name:'gadget', price:99},{name:'thingamajig', price:101} ]}">
<tr>
    <th>Name</th>
    <th>Price</th>
</tr>
<tr ng:repeat="product in data.items">

    <td>{{product.name}}</td>
    <td>{{product.price}}</td>
</tr>
<tr>
    <td></td>
    <td>{{data.items.$sum('price')}}</td>
</tr>

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

Issues with Retrieving Nested Arrays

I am encountering an issue with an object within an array and I am looking to specifically display that as an array. data1 const data1 = [ { "id": "01", "info": "fefef", "sub": "hieei&qu ...

Leveraging JSON data to dynamically update text in HTML using AngularJS

I'm in the process of developing a new web application using AngularJS. This application will have a main page with a side menu structure defined by a JSON file. Here is a highly simplified example of what the JSON file might look like: G_Main_Menu = ...

The failure to display relevant data from the database when adding new rows to a table

I am dealing with a table that allows users to add and remove rows. There is a select option to choose a customer, which then populates a dropdown in the table with all available products. Once a product is selected, the corresponding fields such as price, ...

Clicking the button will trigger the onclick event

I'm working on a button component in TypeScript and I have encountered an issue with passing the event to the submitButton function. import * as React from 'react'; interface Props { className?: string; text: string; onClick?(event: Reac ...

Struggling to send the correct array in response to an HTTP request. Is there a way to efficiently send results from a function using expressjs?

Issue Summary: Currently, I am facing a challenge while working on a software program that relies on an SQL database at the backend and utilizes the npm SQLite3 module for communication purposes. The problem arose when performing an HTTP request to the ser ...

Tips for inserting user input into an array and showcasing it

const [inputValue, setInputValue] = useState(""); return ( <input onChange={(event) => setInputValue(event.target.value)} /> <p>{inputValue}</p> ); I'm facing a problem where I need to take input from a user and store it in ...

What is the best way to capture the output of a script from an external website using Javascript when it is returning simple text?

Recently, I decided to incorporate an external script into my project. The script in question is as follows: <script type="application/javascript" src="https://api.ipify.org"> </script> This script is designed to provide the client's IP ...

Showing options in a menu to choose from

I'm currently working on implementing a dropdown menu for a news website. When the user selects '1' from the dropdown list, the page should display content corresponding to that selection. If the user selects '2', the page ...

Transform an SVG file into a PNG format using the image's path as the guideline

Can an SVG image be converted to the PNG format within an angular project? I came across a library called save-svg-as-png, but it requires the id of an svg canvas. However, in my code, I am using the img tag to display the SVG image: <img src="path/to ...

Utilizing ng-class to dynamically change glyphicons for sorting a table

I've been encountering some difficulties with implementing the ng-class feature. I have a table that can be sorted in ascending and descending order by clicking on the glyphicon-chevron-down. However, I'm struggling to get it to work properly. M ...

JavaScript: Retrieve values from individual textareas with identical class names

Imagine you have multiple text areas like the ones below: <textarea class='save'></textarea> <textarea class='save'></textarea> <textarea class='save'></textarea> All of them are assigned ...

"Calculating the total value of an array based on its individual elements

My API response includes committers to a git project, but some members are repeated because they share the same name with different email addresses. Example response: [ {"id": "122334", "name": "bob", "commits":10, "email": "<a href="/cdn-cgi/l/emai ...

How would you go about creating a VueJS component that displays a table with a set number of columns and automatically distributes the cells within them?

Hey there! I'm currently working with a VueJS component that looks like this: <template> <div> <table> <tbody> <tr v-for="(item, index) in items" :key="index"> <t ...

What is the best way to ensure a navigation link stops scrolling at the bottom of a navbar that is set to position: sticky?

I am utilizing Bootstrap 5 for my website, and I have a sticky-top attribute on my navbar. When I click on one of the links in the navigation bar, the page scrolls to that section, but some of the content goes behind the navbar. I am looking for a way to m ...

jQuery's event delegation feature fails to work in conjunction with AJAX requests

I'm currently facing issues with jQuery's on event delegation: Below is the code snippet I am working with: HTML portion: <body> <!-- Page Content Wrapper--> <div id="sb-site"> <div id="overlay">& ...

Extracting information from the responseText of an XMLHttpRequest

Using AJAX, I am retrieving some data that I need to manipulate after the AJAX call completes. However, I am facing an issue where I can't seem to manipulate the response. Here is the code snippet: function testAjax() { direc = "co ...

Iterate through each image within a specific div element and showcase the images with a blur effect applied

I have a div with multiple images like this: <div class="am-container" id="am-container"> <a href="#"><img src="images/1.jpg"></img></a> <a href="#"><img src="images/2.jpg"></img>< ...

Loop through unique IDs using AngularJS ng-repeat

I am just starting to delve into AngukarJS and ionic framework, embarking on the journey of creating an app with a structured tree layout as follows: Home Tab (list of books) (templates/allbooks.html) > unique book (book description and chapters) (tem ...

construct a table utilizing JSON information

If I have data returned from an ajax call that needs to be processed, a table like the following needs to be created: ID NAME Object Type ============================================== 1 SWT-F1-S32-RTR-1 Network Switch 2 ...

Can someone provide instructions on how to convert base64 data to an image file

I'm utilizing the vue-signature Library but I am unsure how to download the base64 data that is generated as an image. Here is the link to the library: https://www.npmjs.com/package/vue-signature. I have gone through the documentation and noticed that ...