No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Selecting Items in Quasar Data Tables Externally

    Help
    1
    1
    892
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      randomruss last edited by

      I have a data table that has checkboxes as a selection mechanism. There is a button outside the datatable which will automatically select an item from the table. When I push this button with no prior selection it works fine but when pushing this button after another selection has been made I get the following error:

      [Vue warn]: Duplicate keys detected: ‘1031’. This may cause an update error.

      found in

      —> <QTable>
      <QCard>
      <QSlideTransition>
      <QCollapsible>
      <QItem>
      <DEVICES> at src\components\devices.vue
      <QPageContainer>
      <QLayout>
      <LayoutDefault> at src\layouts\default.vue
      <Root>

      The code I have is shown below:

      <q-btn
        @click= selectPrime()>
      </q-btn>
      <q-card flat>
        <q-table
          :columns="devices_cols_sample"
          :data="devices_sample"
          :filter = "filter"
          :separator="separator"
          row-key="id"
          color="positive"
          :selection="selection"
          :selected.sync="selected"
        >
        </q-table>
      </q-card>
      

      The table columns are defined like so:

        devices_cols_sample: [
          {
            label: 'GUID',
            name: 'deviceGuid',
            width: '200px',
            field: 'guid',
            type: 'string',
            filter: true
          }
        ]
      

      And the data is:

        devices_sample: [
          {
            guid: 'SP-779',
            id: 1013
          },
          {
            guid: 'SP-780',
            id: 1031
          }
        ]
      

      The method I am using to select an item from the table (external to the table) is the following:

      selectPrime(){
        this.selected[0].id = 1031
      }
      

      Is there a better way of selecting a checkbox from a DataTable outside of the DataTable? Is this perhaps a bug in Quasar?
      Shouldn’t any changes to the selected variable happen simultaneously inside the dataTable. It seems that the new value is being checked but the old value isn’t clearing. If this is a bug, is there workaround?

      1 Reply Last reply Reply Quote 0
      • First post
        Last post