Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

merge 2 values and put in a v-data-table column (Vuetify)

Is it possible to merge to values and put into one column in v-data-table?

List.vue

<template>
  <v-app>
        <v-data-table
          :items="items"
          :headers="headers"
        />
  </v-app>
</template>

<script>
export default {
  data() {
    return {
      items: [
         { first_name: "Peter", last_name: "Johnson" },
         { first_name: "Simon", last_name: "Walker" }
       ],
      headers: [
        { text: "first_name", value: "first_name" },
        { text: "last_name", value: "last_name" },
      ]
    };
  }
};
</script>

For example I want to put Peter Johnson in Full name column of my v-data-table, While it doesn't have Full name column.

like image 994
Fred II Avatar asked Feb 19 '20 14:02

Fred II


People also ask

How to style content inside vuetify data table rows?

You can style the content inside your Vuetify data table rows as per your requirement using Typography classes. I've added onclick listener on the tr tag that toggles the value key of the particular row item which is bound to the star icon. So inside the methods in your JS I've added the toggle function:

What is the architecture of a DataTable in Vue?

The architecture of a table is such that a user can quickly scan the displayed information. A data table organizes information using column and rows, and a general DataTable has the following components: Create Vue project by using the following command. Get inside the project directory.

How to enable filtering feature in data tables in Vue?

Add a search prop to enable filtering feature in Data Tables is very easy in Vue with Vuetify.js. Start the app in the browser. Finally, we have completed the Vue Table tutorial with various examples, and i hope you liked this tutorial.

How to combine data from two tables in Power BI?

03-24-2019 11:30 PM First, if you use SQL tables, then you shoud apply full outer join to combine both the columns from the tables and create a dataset in Power BI. Second, if you Datasource is like Excel,etc.. then you can append both the dataset in Power BI query editor.


Video Answer


1 Answers

You can render a virtual column with the use of slots with v-data-table. But you need to have a column full_name.

<v-data-table :headers="headers" :items="items">
  <template #item.full_name="{ item }">{{ item.first_name }} {{ item.last_name }}</template>
</v-data-table>
export default {
  data() {
    return {
      items: [
        { first_name: "Peter", last_name: "Johnson" },
        { first_name: "Simon", last_name: "Walker" }
      ],
      headers: [{ text: "Full Name", value: "full_name" }]
    };
  }
};

https://vuetifyjs.com/en/components/data-tables#slots

like image 138
Pierre Said Avatar answered Nov 05 '22 04:11

Pierre Said