Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
vetify v-data-table with fetch data

i am using v-data-table for my project. The data I pull from the backend comes as item id. How can I match the incoming id with the object id in the categories and reflect the category name to the table?

    <v-data-table :headers="headers" :items="fetchCategories" class="elevation-1" :search="search">
  <template slot="item" slot-scope="props">
    <tr>
      <td>{{ props.item.id }}</td>
      <td class="text-xs-right">{{ props.item.testId }}</td>
   


      <td class="justify-center px-0">
        <v-btn icon class="mx-0" @click="editItem(props.item)">
          <v-icon class="mx-0 primary--text white--text">edit</v-icon>
        </v-btn>
        <v-btn icon class="mx-0" @click="deleteItem(props.item)">
          <v-icon class="mx-0 red--text white--text">delete</v-icon>
        </v-btn>
      </td>
    </tr>

DATA

categories: [
  {
    id: 1,
    name: 'Category 1',
  },
  {
    id: 2,
    name: 'Category 2',
  },
  {
    id: 3,
    name: 'Category 3',
  },
  {
    id: 4,
    name: 'Category 4',
  },
  {
    id: 5,
    name: 'Category 5',
  }

fetchCategories:[]

METHODS

created() {

fetch('example-backend.com/categories')
  .then((response) => {
    return response.json();
  })
  .then((data) => {

    this.fetchCategories = data;
  });

},

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use additional method to convert that. I use lodash

import _ from "lodash"
findInObject(obj,key) {
  return _.find(obj, function(o) {return o.id == key}) // this will return object from categories data that matched the key
}

and in your template slot, instead of this:

<td>{{ props.item.id }}</td>

you can use this

<td>{{ findInObject(categories, props.item.id).name }}</td>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda