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

    [Solved] Q-Table selected rows is not updated

    Framework
    2
    4
    1026
    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.
    • S
      Stanley last edited by Stanley

      In the data table, there is a delete button. Suppose there are two items, I set the checkbox of first item as selected, then it will be deleted. Now the second item is not checked, but I can still delete it. It seems variable itemSelRows is not cleared after first deletion.

      <q-table :data="items"
            :columns="itemColumns"
            selection="single"
            :selected.sync="itemSelRows"
            row-key="itemNo"
      >
        <q-tr slot="body" slot-scope="props" :props="props">
           <q-td auto-width><q-checkbox color="primary" v-model="props.selected"/></q-td>
           <q-td key="itemNo" :props="props">{{ props.row.itemNo }}</q-td>
        </q-tr>
        <div slot="top-left" slot-scope="props">
           <q-btn icon="delete" @click="deleteItem()" />
        </div>
      </q-table>
      
      deleteItem () {
          if (this.itemSelRows.length === 0) {
            this.$q.notify('please select one entry')
            return
          }
         // the second time, itemSelRows is not cleared
      }
      
      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        Um, it’s up to you to do the clearing/ deleting etc. in your component. The code above doesn’t do anything really.

        Scott

        S 1 Reply Last reply Reply Quote 0
        • S
          Stanley @s.molinari last edited by

          @s-molinari Hi Scott, I thought it is two-ways binding. It seems we have to maintain it manually. Thanks!

          1 Reply Last reply Reply Quote 0
          • s.molinari
            s.molinari last edited by

            @Stanley - there is no two-way binding for a button that is being used to trigger a method to delete the values in the array of rows.

            Scott

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