11 Replies Latest reply on Oct 22, 2010 11:44 AM by Flex harUI

    Easy way to have a dropdownlist with without a separate dataProvider?

    JoshBeall Level 1

      Hi All,

       

      Sometimes I've got a DropDownList control that I don't want or need to bind to a separate dataProvider object.  For instance, if I want a DropDownList that the user and use to select the quantity of something--I just want a DropDownList that lists numbers 1 through 10, perhaps.

       

      I first tried something like this:

       

      <s:DropDownList y="0" right="0" width="50" dataProvider="{[1,2,3,4,5,6,7,8,9,10]}" />

       

      But the compiler throws an error saying it can't convert from an Array to an IList.

       

      I eventually came up with this, and it works, but it's not as compact as I was hoping.  Is this the simplest way, or can I refine this further?

       

      <s:DropDownList y="0" right="0" width="50" id="numberOfInstructorsDropDownList">
           <s:dataProvider>
                <s:ArrayList>
                     <fx:int>1</fx:int>
                     <fx:int>2</fx:int>
                     <fx:int>3</fx:int>
                     <fx:int>4</fx:int>
                     <fx:int>5</fx:int>
                     <fx:int>6</fx:int>
                     <fx:int>7</fx:int>
                     <fx:int>8</fx:int>
                </s:ArrayList>
           </s:dataProvider>
      </s:DropDownList>