angular-zorro nzShowCheckbox needs to be clicked twice to select, the meaning of Indeterminate

1. nzShowCheckbox needs to be clicked twice to select

 

the reason:

Data.checked's true and false value switching has been completed automatically, and should not be switched again

 

Second, the meaning of Indeterminate

When the value of indeterminate is true, the selected state is forced to change to-(only affect the interface display, not the data)

When is indeterminate true?

Except for the following two states

(1) All radio buttons are selected

(2) All radio buttons are unchecked

Namely: Partially selected

 

 

 

Attached:

itemList is list data

  checkAll() {
    if(this.allChecked_table){
      this.itemList.forEach(i=>i.checked=true)
    }else{
      this.itemList.forEach(i=>i.checked=false)
    }
    this.ensure_state_indeterminate_table()
  }

  checkOne() {
    this.ensure_state_indeterminate_table()
    this.ensure_state_allChecked_table()
  }

  ensure_state_indeterminate_table(){
    let is_all_check = this.itemList.every(i=>i.checked==true)
    let is_all_not_check = this.itemList.every(i=> (i.checked==false || i.checked==undefined || i.checked==null))
    if(is_all_check || is_all_not_check){
      this.indeterminate_table = false
    }else{
      this.indeterminate_table = true
    }
  }

  ensure_state_allChecked_table(){
    let is_all_not_check = this.itemList.every(i=> (i.checked==false || i.checked==undefined || i.checked==null))
    if(is_all_not_check) {
      this.allChecked_table = false;
    }else{
      this.allChecked_table = true;
    }
  }

 

Guess you like

Origin blog.csdn.net/u013595395/article/details/113767224