S
S
stimul7772021-05-11 19:32:05
Vue.js
stimul777, 2021-05-11 19:32:05

How to make a drop down table?

Hello everyone, how to make a dropdown table in Vuetify? So that when you click on a line, it opens and there is another table in it?
609ab12d84a30059258901.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2021-05-11
@stimul777

Use the slot expanded-item:

<v-data-table
  :headers="mainTableHeaders"
  :items="mainTableItems"
  item-key="mainTableItemKey"
  show-expand
>
  <template #expanded-item="{ headers, item }">
    <td :colspan="headers.length">
      <v-data-table
        :headers="nestedTableHeaders"
        :items="item.nestedTableItems"
      ></v-data-table>
    </td>
  </template>
</v-data-table>

https://jsfiddle.net/krg8ac7s/UPD
. Somehow missed:
when clicking on a line

We remove show-expand, add a click handler, where the display of additional content will be switched manually:
methods: {
  onRowClick(item, row) {
    row.expand(!row.isExpanded);
  },
  ...

<v-data-table
  @click:row="onRowClick"
  ...

A
alaskafx, 2021-05-11
@alaskafx

Hello, v-show or v-if help.
You create, for example, table: false, and in v-if for the opening itself you do v-if='table', and then add a method with an event handler for clicking what you need)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question