Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

490
Views
How to sum total in table vuejs?

There are two rows of data row,

<tr v-for="(data, index) in result_estimate.item_tabel" :key="index">
  <td>
    <pre> sub total : {{ambilaja(formatPrice(ambilPrice[index] - (ambilPrice[index] * subtotalRow[index])))}}</pre>
  </td>
<tr>
<div> total : {{this.totals}}</div>

The result of the above value is the total of each of each row, here I pass the value into the function ambilaja().

 return {
    totals : 0
    },
    computed : (){
         ambilaja: function(){
              return (value) => this.lempar(value)
         },
    }, 
    method : {
       lempar(data){
          console.log(data) 
          result console 
          30002 -> total row index 0
          2003 -> total row index 1
       }
    }

How to add up the total ? ex : 30002 + 2003 = this.totals

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Not sure what type of data is in ambilPrice or subtotalRow but you can just add another method and pass parameters to do calculations.

<tr v-for="(data, index) in result_estimate.item_tabel" :key="index">
  <td>
    <pre> sub total : {{ambilaja(formatPrice(ambilPrice[index] - (ambilPrice[index] * subtotalRow[index])))}}</pre>
  </td>
<tr>
<div> total : {{calTotals(ambilPrice, ambilPrice, subtotalRow)}}</div>

Vue Code:

return {
  totals : 0
  },
  method : {
    calTotals(ambilPriceArr, subtotalRow, index) {
      this.totals = this.totals + ambilPriceArr[index] - (ambilPriceArr[index] * subtotalRow[index]);
      return this.totals;
    },
}
about 4 years ago · Juan Pablo Isaza Report

0

The best approach for this issue is to use computed property for the total as like below.

computed() {
    total: function(){
        let sum = 0;
        this.result_estimate.item_tabel.forEach(item => sum += this.calculatePriceForIndividualRow(item));
        return sum;
    },
},

Where calculatePriceForIndividualRow is the function that will calculate sum for each row.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!