Flex 4.1 Spark List clears selectedItems property when changing dataprovider
I found an issue in the Flex framework. I use Flex 4.1. In skin class of the MySkinnableContainer, List component defined:
<s:List id="myList" allowMultipleSelection="true"/>
Then in MySkinnableContainer, I dynamically change myList.dataProvider and myList.selectedItems. 开发者_JS百科But, when I am define myList.dataProvider = new ArrayCollection([1,2,...]), the myList.selectedIndices doesn`t clear. I catch exception when call myList.selectedItems, because myList.selectedIndices is old. myList.selectedIndices = [], and so on, doesnt work. Help me, please. Thank, you.
Fixed. Solution is, by steps:
- First, when you set dataProvider = new myArrayCollection([1,2...]), then, you must waiting for updateComplete event - the selectedItems and selectedIndices now is clear.
- Second, you can set your own selectedItems, ex. selectedItems = new Vector.int(), and before you call getter selectedItems, you must waiting for valueCommit event.
- Third, now you can call getter selectedItems wothout exception.
精彩评论