admin管理员组

文章数量:1287969

In ponent of office 365 fabric ReactJs exists such ponent. It has _getSelectionDetails() method which counts selected items from list I want to make method which will reset it and will deselect items in list. For example we have button and when we press it, we reset all the items in the list, which we marked before. I tried to do :

_resetSelectedItems() :{
 this.setState ({ selectionDetails: 0 }) 
}

After I call it, it sets new state and sets 0, but items which were selected before remain selected, diselecting doesn't happen. How I can deselect items?

In ponent of office 365 fabric ReactJs exists such ponent. It has _getSelectionDetails() method which counts selected items from list I want to make method which will reset it and will deselect items in list. For example we have button and when we press it, we reset all the items in the list, which we marked before. I tried to do :

_resetSelectedItems() :{
 this.setState ({ selectionDetails: 0 }) 
}

After I call it, it sets new state and sets 0, but items which were selected before remain selected, diselecting doesn't happen. How I can deselect items?

Share Improve this question asked Jul 25, 2017 at 12:45 Sam FisherSam Fisher 8482 gold badges15 silver badges37 bronze badges 1
  • 1 try using this._selection.XXXx , you have full documentation here: github./OfficeDev/office-ui-fabric-react/blob/master/… – José Quinto Zamora Commented Jul 25, 2017 at 12:57
Add a ment  | 

1 Answer 1

Reset to default 13

this.setState() performs a shallow merge of this.state into the new state, e.g. if this.state have selectionDetails and many more objects. this.setState ({ selectionDetails: 0 }) will update only selectionDetails other will remain unchange. You have to cleanup other objects manually.

ref : this.setState

Update :

finally i got it.... this._selection.setAllSelected(false) will work.

check out my github project or check online.

本文标签: javascriptHow to reset selected items from the listStack Overflow