[Vuejs]-How to set default expand in a q-table?

1👍

There are two ways to do that.

You can pass expanded prop in q-table or can use v-model:expanded="expandedRows" if want to sync expanded rows.

<q-table
    ref="mytable"
    :expanded="expandedRows"
    ...
>
</q-table>

and define expandedRows ref with key of first row in setup.

const expandedRows = ref(["key-of-first-row"]);

and second way is with setExpanded method.

  const mytable = ref(null);

  onMounted(function () {
    mytable.value.setExpanded(["key-of-first-row"])
  })

Note:- When you ask any question in any forums, always put the code you have tried.

Leave a comment