Single Selection on datatable activating all checkboxes



  • I have been trying to use the single selection feature on datatables on v1.0.0-beta.18 and I am facing an issue where I need a single selection on a row, when I select any row checkbox, all rows are selected, but only the selected row is showing up on the selected array.

    Template:

    <q-table
    :data="tenants"
    :columns="columns"
    row-key="name"
    :filter="search"
    selection="single"
    :selected.sync="selected"
    >
      <template v-slot:top-right>
        <q-input borderless dense debounce="300" v-model="search" placeholder="Search">
        <template v-slot:append>
          <q-icon name="search"/>
          <q-btn flat round icon="cancel" @click="resetSearch"/>
        </template>
      </q-input>
    </template>
    </q-table>
    

    Script:

    data: () => ({
        search: '',
        tenants: [],
        selected: [],
        columns: [
          {
            name: 'uid',
            label: 'UID',
            field: 'uid',
            required: true,
          }, ... etc
    

    Screenshot attached. As it can be seen only first row is selected (ripple is still seen)
    Screen Shot 2019-04-24 at 2.35.00 PM.png

    Would appreciate any help to trouble shoot this issue.

    PS: ‘QCheckbox’ is registered in quasar config file



  • The row-key="name" is missing in the object. You have that within details. Btw this would also happen if you did not specify the attribute row-key.



  • Thanks for pointing that out. For some reason I was under the impression row-key="name" referred to the name field in the column array



  • @vrn-dev it refers to a prop of the object array you passed to data prop, usually i set it as the __index since quasar sets it uniquely for each row than a name which has tendencies to be duplicated.


Log in to reply