[Vuejs]-Vue JS Checkbox select all With Nested Array

0๐Ÿ‘

โœ…

i figured it out how to solve this problem: count array index ,
thanks advanced

<b-card no-body class="mb-1" v-for="(users, idx) in userlistes" :key="users.id">
      <b-collapse
        :id="`accordion-${users.id}`"
        accordion="table-accordion"`enter code here`
        role="tabpanel"
      >
        <table class="table table-striped table-bordered">
          <thead>
              <th>
                 <label class="form-checkbox">
                   <input
                     type="checkbox"
                     @click="clickCheckAll(idx)"
                     :value="allChecked(idx)"
                   />
                   <i class="form-icon"></i>
                </label>
              </th>
            </tr>
          </thead>
        </table>
      </b-collapse>
    </b-card>
 export default {
      data() {
        return { //.. };
      },
      methods: {
        allChecked(idx) {
          return this.userlistes[idx].worklists.some((el) => el.hr_checked)
        },
        clickCheckAll(idx) {
          this.checkAll = !this.checkAll;
          const currentUser = this.userlists[idx]
          for (let i = 0; i < currentUser.worklists.length; i++) {
            currentUser.worklists[i].hr_checked = this.checkAll;
          }
        },
      },
    }

Leave a comment