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

89
Views
How to return a list of value in all cells of a column with VueJS

I have an HTML table like this:

  <thead>
    <tr>
      <th scope="col">ID</th>
      <th scope="col">Nouveaux FDES</th>
      <th scope="col"></th>
    </tr>
  </thead>
  <tbody>
    <tr v-for="row in rows">
      <td> {{ row.details.id_inies }} </td>
      <td> <a :href="row.url" target="_blank" rel="noreferrer noopener">{{ row.name }}</a></td>
      <td style="text-align: center; vertical-align: middle;"> <input v-model="row.isSelected" type="checkbox"> </td>
    </tr>
  </tbody>

My goal is to get value in cells of the column ID and only the ones which are selected by user using the checkbox

I try something like this but it doesn't work:

{
     const selectedFDES = this.rowsScraped.filter((fdes) => fdes.isSelected === true);
     const idList = selectedFDES.reduce((acc, item) => {
       acc[item.details.id_inies] = [];
       return acc;
     }, []);
     console.log(idList);
     this.$http.admin.putScrapedFDES(idList);
   }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your reducer function doesn't make much sense. It should probably look like this:

const selectedFDES = this.rowsScraped.filter(r => r.isSelected);
const idList = selectedFDES.reduce((acc, item) => {
  acc.push(item.details.id_inies);
  return acc;
}, []);
console.log(idList);
this.$http.admin.putScrapedFDES(idList);

For your case, I believe a .map() would be shorter, cleaner and more readable:

const idList = this.rowsScraped
  .filter(r => r.isSelected)
  .map(r => r.details.id_inies);
this.$http.admin.putScrapedFDES(idList);

See it working here:

new Vue({
  el: '#app',
  data: () => ({
    rows: ['First', 'Second', 'Third']
      .map((name, i) => ({
        name: `${name} row`,
        details: {
          id_inies: i + 1,
        },
        url: '#',
        isSelected: false
      }))
  }),
  computed: {
    selectedRows() {
      return this.rows
        .filter(row => row.isSelected)
        .map(row => row.details.id_inies)
    }
  },
  watch: {
    selectedRows(newVal, oldVal) {
     // This runs every time selectedRows changes value
     console.log({ newVal, oldVal });
    }
  }
})
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<div id="app">
  <table>
    <thead>
      <tr>
        <th scope="col">ID</th>
        <th scope="col">Nouveaux FDES</th>
        <th scope="col"></th>
      </tr>
    </thead>
    <tbody>
      <tr v-for="row in rows">
        <td> {{ row.details.id_inies }} </td>
        <td> <a :href="row.url" target="_blank" rel="noreferrer noopener">{{ row.name }}</a></td>
        <td style="text-align: center; vertical-align: middle;"> <input v-model="row.isSelected" type="checkbox"> </td>
      </tr>
    </tbody>
  </table>
  <pre v-text="selectedRows" />
</div>

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!