I install this library http://ift.tt/25Fq985 and it works very well with me now I need to use select all checkbox but the problem faced me is how to make all of the checkboxes be checked or unchecked
I try this in the single check box and it works fine
<QCCheckboxVIcon onPressed={(isChecked) => this.selectCheckedChanged(isChecked, item.BasketId, item.Amount)}
freez={freez} selected={ this.state.selectAll }
ref={(c) => this._check = c} />
this is the select all button
<QCCheckboxVIcon onPressed={(isChecked) => this.togleSelectAll(isChecked,data)}
selected={ this.state.selectedCheckboxs == data.length}
freez={freez} />
and this is the function I used
togleSelectAll(isChecked,data) {
let itms = [];
if(isChecked) {
for(var i=0; i < data.length; i++) {
alert( data[i].BasketId+' '+ data[i].Amount)
selectedItems.push({BasketId: data[i].BasketId, Amount: data[i].Amount});
selectedItems.map((itm, index) => {
itms.push(itm.BasketId);
});
this.props.onSelectedItemsChanged(itms);
freez = true;
let total = 0;
selectedItems.map((itm, index) => {
total += itm.Amount;
});
this.setState({
totalAmount: total,
selectedCheckboxs: this.state.selectedCheckboxs ,
});
setTimeout(() => {freez = false;}, 3000);
}
} }
it works great in getting total and know items but the problem is it didn't highlight the children checkboxes as this image
Aucun commentaire:
Enregistrer un commentaire