Flex List selected entire list by default
I am currently working on a project in Flex and I am having a hard time having a l开发者_如何学Pythonist's contents ALL be selected by default. Wondering how to do this. Appreciate any help.
<mx:List id="list" dataProvider="{dp}" allowMultipleSelection="true"/>
I'm just trying to have the list all selected.
Try to use something like the following:
<mx:List id="list" dataProvider="{dp}" allowMultipleSelection="true"
creationComplete="event.currentTarget.selectedItems = event.currentTarget.dataProvider.source"/>
I ended up trying many different variations to get the list to be all selected. This is the one that ended up working.
var arr:Array = new Array();
for (var i:Number = 0; i < (list.dataProvider as ArrayCollection).length; i++) {
arr[i] = i;
}
list.selectedIndices = arr;
精彩评论