1

I have a conceptual question about data tables and objects passed into it.

Let's assume I have the normal data tables CRUD example from vuetify: https://codepen.io/rasenkantenstein/pen/MWYEvzK

ingredients:
        [
          {
            ingName: 'Yogurt',
            amount: 100,
            measure: 'gramm'
          },
          {
            ingName: 'Ice',
            amount: 50,
            measure: 'ml'
          }
        ]

At line 65 (JS) I have created a new Object-Array with ingredients, so one dessert has at least one ingredient (or more).

I am struggling to implement this into the edit table. Also, I would like to output the ingredients (e.g. comma separated) inside the table (and somehow load them in the form).

Are objects like this at all editable with Vuetify datatables? Would it be a good approach to loop through the ingredients array for the pop up?

1 Answer 1

3

You can use the v-slot prop exactly like how your using it for your Edit/Delete actions.

<template v-slot:item.ingredients="{ item }">
  <span v-for="ingredient in item.ingredients">
   {{ ingredient.ingName }}
  </span>
</template>

Using the v-slot property essentially overwrites the header value that you've specified. Since there is a header named ingredients, you need to overwrite it using v-slot:item.ingredients. You can use this as well to alter/format values before they're displayed in the table (i.e adding commas to large numbers, formatting money values, creating lists, etc).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.