1

Is there a way to sort a v-data-table by the selection column? I would like to multisort my v-data-table. First by selection, so the selected ones are always on top and second by name. So far I got this:

 <template>
  <v-app>
    <div id="app">
      <v-data-table
        :headers="tableHeaders"
        :items="selectables"
        :show-select="true"
        :sort-by="['isSelected', 'name']"
        multi-sort
        v-model="output"
        return-object
      >
      </v-data-table>
    </div>
  </v-app>
</template>

<script>
export default {
  data() {
    return {
      output: {},
      tableHeaders: [
        {
          text: "name",
          value: "name",
        },
      ],
      selectables: [
        {
          name: "toni",
        },
        {
          name: "hans",
        },
        {
          name: "fritz",
        },
      ],
    };
  },
};
</script>
H0fi
  • 53
  • 1
  • 5
  • it seems as if you just need to create an array and serve it to the sort-by prop – Ezycod Oct 28 '20 at 06:17
  • The v-data-table provides the selection and seems to handle it internally. My problem now is to access that property and sort the table by it – H0fi Oct 28 '20 at 07:35

0 Answers0