We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Assigning Initial Value to a Combo Box

sfletcher1959
on
Medium Priority
773 Views
Last Modified: 2013-11-11
I can't figure out why the initial values of my ComboBox is not right. I thought I had this working correctly at one point.

If I assign the same value to a Text field it is correct.

Thanks!
My Text Field:
 
   <mx:Text text="{chart.chartType}"/>
 
 
My ComboBox:
 
<mx:FormItem label="Chart Type">					
      <mx:ComboBox id="cbChartType" Text="{chart.chartType}">
		<mx:dataProvider>
			<mx:Object label="Chart" data="Chart"/>
			<mx:Object label="Piechart" data="Piechart"/>
			<mx:Object label="Form" data="Form"/>
			<mx:Object label="List" data="List"/>					
		</mx:dataProvider>
      </mx:ComboBox>

Open in new window

Comment
Watch Question

Commented:
<mx:ComboBox id="cbChartType" selectedIndex="1">

Its a bad solution I don't use that ComboBox I use this one:

http://www.forta.com/blog/index.cfm/2006/11/22/Flex-ComboBox-With-selectedValue-Support

With this CB your binding will work like you want it to.

Author

Commented:
I am getting errors with this: "expecting right brace before data". I copied the example you gave but I must have missed something.



[Bindable]
            private var comboChartTypes:Array =
                  [{label:"Chart" data="Chart"},
                   {label:"Piechart" data="Piechart"},
                    {label:"Form" data="Form"},
                    {label:"List" data="List"}];



Author

Commented:
Oh, I see my mistake!

Commented:
Are you sure its erroring on this line?

Author

Commented:
New Error: 1046: Type was not found or was not a compile-time constant: ComboBox2.

  <ns1:ComboBox2 id="cbChartType" dataprovider= "{comboChartTypes}" selectedValue="{chart.chartType}"/>

Is there something I should have downloaded from Ben's site?

Thanks!      

Commented:
What name did u give to the MXML from Bens combo box: ComboBox2 ?  Is it in the same directory?

Author

Commented:
Its name is ComboBox2 but I had to adjust the directory to xmlns:ns1="util.*" because I put it in the util directory.

So no more errors related to that but now I get a new error:

Cannot resolve attribute 'dataprovider' for component type util.ComboBox2.


Here is my code:
<mx:FormItem label="Chart Type">                              
                      <ns1:ComboBox2 id="cbChartType" dataprovider= "{comboChartTypes}" selectedValue="{chart.chartType}"/>      
              </mx:FormItem>

Here is my VAR:
[Bindable]
            private var comboChartTypes:Array =
                  [{label:"Chart", data:"Chart"},
                   {label:"Piechart", data:"Piechart"},
                    {label:"Form", data:"Form"},
                    {label:"List", data:"List"}];
      
      
Commented:
dataprovider  should be  dataProvider

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks, again for your help Jones911!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.