0

I have a problem with nesting the expandable row components in my table. Currently, I just created <TableSubRow /> in my <TableRow /> component, then in <TableSubRow /> I created <TableSecondSubRow />.

TableSection.vue

<template>
  <tbody>
    <TableRow
      v-for="(row, index) in p.rowsList"
      @send-time-log-element="(value) => e('sendTimeLogElement', value)"
      @send-expand-status="sendExpandStatus"
      @send-selected-row="sendSelectedRow(row)"
      :key="index"
      :headers="p.headers"
      :row="row"
      :tasksTitle="p.tasksTitle"
      :sub-tasks-title="p.subTasksTitle"
      :expandCell="p.expandCell"
      :secondExpandCell="p.secondExpandCell"
      :same-cell-titles="p.sameCellTitles"
      :theme="p.theme" />
  </tbody>
</template>

TableRow.vue

<template>
  <tr>
    <!-- row template (doesn't matter in this case) -->
  </tr>

  <TableSubRow
    v-for="element in p.row[p.tasksTitle]"
    v-if="rowExpanded"
    @send-time-log-element="(value) => e('sendTimeLogElement', value)"
    @change-check-status="checkRow(element)"
    :key="element"
    :element="element"
    :headers="p.headers"
    :row="p.row"
    :tasksTitle="p.tasksTitle"
    :sub-tasks-title="p.subTasksTitle"
    :expand-cell="p.expandCell"
    :second-expand-cell="p.secondExpandCell"
    :same-cell-titles="p.sameCellTitles"
    :theme="p.theme" />
</template>

TableSubRow.vue

<template>
  <tr>
    <!-- sub row template -->
  </tr>

  <TableSecondSubRow
    v-if="isExpanded"
    @send-time-log-element="(value) => e('sendTimeLogElement', value)"
    @change-check-status="checkRow(p.element)"
    :headers="p.headers"
    :row="p.element"
    :tasksTitle="p.tasksTitle"
    :expand-cell="p.expandCell"
    :second-expand-cell="p.secondExpandCell"
    :same-cell-titles="p.sameCellTitles" />
</template>

In this case, I had to send props for each subrow (e.g. for expand status), which is bad I think. Of course, it works for statically defined amount of subrows.

enter image description here

How could I make dynamic expandable rows like on the screen above?

I tried to create a dynamic subrow component with subrow component (like recurrence?), but I had many issues there and didn't have enough time for this.

Now I need a dynamic expandable table and cannot define subrows static in code. It should be created automatically by backend data (nested objects or something like that).

3
  • what does didn't have enough time for this mean? are you perhaps looking for a "treeview"? Commented Aug 28, 2024 at 6:10
  • @JaromandaX I was experiencing this problem few months ago, there was no time for it then (2 sub rows were enough) - doesn't matter. Yes, I'm looking for treeview table, but cannot create that in code - as i posted. Commented Aug 28, 2024 at 6:26
  • perhaps be inspired by others who have created vue3 treeview - there are many - I remember using one for vue2 years ago, so not relevant to you Commented Aug 28, 2024 at 6:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.