1 Reply Latest reply on Aug 7, 2006 1:08 PM by jtan

    Problem With selectedItems

      Have a List object , populated with 20 items from an XML file via the dataprovider. I want to pre-select the first 5 of them for the user, showing each as already selected. What I've found the docs to say is to pass an array of the items you want selected to the selectedItems() of the list object (a setter?). Here's the specific code items I've made and then pulled out from all the source code for use here. I've even tried the selectedItems = <array> and that didn't seem to work.

      What is the trick to pre-selecting items in a List object? Thanks for any help in advance.

      // In my Script block
      [Bindable] public var selMkts:Array = [1,2,3,4,5];

      public function initSelMkts():void {

      // Inside a panel component
      <mx:List id="sacBudgets"
      width="230" height="300"
        • 1. Problem With selectedItems
          I think that if you just want to preselect the first five items in the List regardless of what that data is, you can use selectedIndices. I tried this and it works:

          sacBudgets.selectedIndices = selMkts;

          hope this helps.
          Joan Lafferty
          Flex QA SDK