mercredi 15 août 2018

How to handle Checkbox group functions using Ant design

I created checkbox component using ant design .If I click check all box then i need to auto trigger checkbox group items

Here my code

 constructor(props) {
    super(props);
    this.state = {
        checkedList: [],
        checkAll: false,
    };
}

 <Checkbox onChange={this.onCheck}
           checked={this.state.checkAll} value={10}>check all</Checkbox>
  <Checkbox.Group onChange={this.onGroupChange} value={this.state.checkedList} style=>
         <Checkbox value={101}>option 1</Checkbox> <br />
         <Checkbox value={102}>option 2</Checkbox>
 </Checkbox.Group>



onCheck =(e)=>{
    this.setState({
        checkAll: e.target.checked,
    });
    ;
}
onGroupChange=(checkedList)=>{
    this.setState({
        checkedList,
        checkAll: checkedList,
    });
}

Can u help me?




Aucun commentaire:

Enregistrer un commentaire