Y
Y
Yan2021-08-23 02:07:34
Vue.js
Yan, 2021-08-23 02:07:34

Vuetify @toggle-select-all - clear checkbox on second click?

There is a selectAllToggle method, which adds rows to the table that are ready to be sent, and blocks the rest.
The essence of my problem is this: I marked these lines with the first click, but I can’t figure out how to clear the table when I click the button again.
6122d7b3d1506423183228.jpeg

<v-data-table
        v-model="selectedDocs"
        v-if="edsList !== null"
        :headers="headers"
        :items="edsList"
        @click:row="showDetail"
        no-data-text="Нет документов"
        item-key="id"
        :server-items-length="totalDocuments"
        :loading="isLoading"
        :show-select="isSelect"
        class="main-table mt-4"
        :options.sync="options"
        hide-default-footer
        :page.sync="page"
        :items-per-page="itemsPerPage"
        @page-count="pageCount = $event"
        @toggle-select-all="selectAllToggle"
        :header-props="{
          'sort-icon':'mdi-swap-vertical'
        }"
      >
        <template v-slot:top>
          <span class="main-table__title">Результаты поиска</span>
        </template>
        <!-- eslint-disable-next-line -->
        <template v-slot:header.data-table-select="{props,on}">
          <v-simple-checkbox
            color="primary"
            v-ripple
            v-bind="props"
            v-on="on"
          ></v-simple-checkbox>
        </template>
        <!-- eslint-disable-next-line -->
        <template v-slot:item.data-table-select="{isSelected, select, item}">
          <v-simple-checkbox
            color="primary"
            v-ripple
            :value="isSelected"
            @input="select($event)"
            v-if="!checkStatusSendMix(item.tk) && checkStatusMix(item)"
          ></v-simple-checkbox>
          <v-simple-checkbox
            color="primary"
            disabled
            off-icon="mdi-close"
            v-else
          ></v-simple-checkbox>
        </template>


selectAllToggle(props) {
      if(this.selectedDocs.length != this.edsList.length - this.disabledCount) {
        this.selectedDocs = []
        props.items.forEach(item => {
          if(!this.checkStatusSendMix(item.tk) && this.checkStatusMix(item)) {
            this.selectedDocs.push(item)
            console.log('this.selectedDocs',this.selectedDocs)
          }
        })
      } else this.selectedDocs = []
    },

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
inFureal, 2021-08-23
@Yan4on

Counting the number of clicks is obvious.
If the first, highlight the ones you need.
If second, remove from table, reset counter to zero

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question