vue.jsvuetify.js

v-data-table checkboxes select all checkboxes


I have a v-data-table implemented, but the show-select checkboxes have a problem. If I click on any one of them, they all select:

data table with nothing selected and one checkbox being clicked

This is the result:

data table with all checkboxes lit up

Also note, the box that should be in the header is missing. Only one box should select when clicked.

Here's the data table:

<v-data-table
    v-model="selected_available_units"
    show-select
    select-strategy="single"
    :headers="new_unit_table_headers"
    :items="unitsStore.available_units_flattened"
    item-key="unit_id"
  >
  <template #item.unit_width="{ item }">
    <div>{{ get_unit_size(item) }}</div>
  </template>
  <template #item.unit_basis_price="{ item }">
    <div>{{ fmt.currency(item.unit_basis_price, item.unit_currency as CURRENCY) }}</div>
  </template>
</v-data-table>

unitsStore.available_units_flattened looks like this:

export type UnitFlattened = {
  unit_id: string,
  unit_name: string,
  unit_width: number,
  unit_depth: number,
  unit_height: number,
  unit_basis_price: number,
  unit_uom: string,
  unit_currency: string,
  unit_is_available: boolean,
  building_name: string,
  location_name: string,
  building_id: string,
  location_id: string,
  company_id: string
}

Headers here:

const new_unit_table_headers : ReadonlyHeaders = [
  {title: 'Location', align: 'start', key: 'location_name'},
  {title: 'Building', align: 'start', key: 'building_name'},
  {title: 'Name', align: 'start', key: 'unit_name'},
  {title: 'Size', align: 'end', key: 'unit_width'},
  {title: 'Basis', align: 'end', key: 'unit_basis_price'}
  // {title: '', align: '', key: ''},
]

Solution

  • Looks like a problem with props: