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

294
Visualizações
How to specify editable column weights in v-data-table?

I have a similar table like the following screenshot shows:

enter image description here

What I'd like to achieve is to assign a weight to each numeric column within this table, i.e., to the columns called "Calories", "Fat", "Carbs", "Protein", and "Iron". To be more concrete, it should be possible in a separate header row to enter a weight (this should be left to the table user, i.e., it should be editable) with which the column values are multiplied and then added up to a weighted sum in a separate column.

Please see the following scratch as for further clarfification.

enter image description here

Is this possible to achieve with v-data-table? Can anyone provide guidance or even a MWE for an editable header row with which to do a weighted summation of the numeric table data?

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

0

you can add an additional row before the actual data with the slot: body.prepend

Your template could look like that:

<div id="app">
  <v-app id="inspire">
    <v-data-table :headers="headers" :items="desserts" :items-per-page="5" class="elevation-1">
      <template #body.prepend>
        <tr class="">
          <td class="text-start"></td>
          <td class="text-start"><input class="red--text" value=1></td>
          <td class="text-start"><input class="red--text" value=1></td>
          <td class="text-start"><input class="red--text" value=1></td>
          <td class="text-start"><input class="red--text" value=1></td>
          <td class="text-start"><input class="red--text" value=1></td>
        </tr>
      </template>
    </v-data-table>
  </v-app>
</div>

Code pen: https://codepen.io/florent-bouisset/pen/QWaRqOy?editors=1010

You should be able to bind input to data and calculate the last column you want

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