vijayakumar flex
vijayakumar flex

Reputation: 583

Flex Combobox Binding Issues

In my application i used combobox and adding value using dataprovider like

   id="teamComboBox" dataProvider="{xml_teamcoupon.lastResult.coupon.teamcoupon_name}

my xml like this

<pick15>
<coupon>
<teamcoupon_id>1</teamcoupon_id>
<teamcoupon_name>teamcoupon1</teamcoupon_name>
coupon></pick15>

so comobobox shows team coupon name . But what i want, ifi choose team coupon name then Correspond teamcoupon id how can i get . i trid teamComboBox.selectedItem.teamcoupon_id but shows error

Upvotes: 0

Views: 671

Answers (2)

Dan Monego
Dan Monego

Reputation: 10087

Bind to the coupon element, rather than the teamcoupon_name element, and then use the labelField attribute of the combobox to reference teamcoupon_name.

<mx:ComboBox dataProvider="{xml_teamcoupon.lastResult.coupon}" labelField="teamcoupon_name" />

Now, you can get the currently selected element using combobox.selectedItem, and the id by referencing combobox.selectedItem.teamcoupon_id.

Upvotes: 1

Christophe Herreman
Christophe Herreman

Reputation: 16085

Since the id node is on the same level as the name node, you'll need to reference the parent node first.

Something like:

teamComboBox.selectedItem.parent().teamcoupon_id

Upvotes: 0

Related Questions