How to implement a data-based ComboBox control with GraniteDS?

567 views Asked by At

I'm trying to integrate Seam and Flex with GraniteDS, with the goal of implemenenting a code generation tool for main use cases of CRUD operations.

One of my needs is to have the possibility to generate a combo box to reference a parent entity from another. For example, a state combo box in my county edition/creation screen.

My first attempts have failed because of lazy loading problems.

Has anyone have code that already does this?

1

There are 1 answers

2
Amarghosh On

You can do this easily using data binding. Just bind the state-combobox's dataProvider to the selectedItem of the country-combobox.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
    <mx:ComboBox id="countries" dataProvider="{xml.country}" labelField="name"/>
    <mx:ComboBox id="state" dataProvider="{countries.selectedItem.state}"/>
    <mx:Model id="xml">
        <root>
          <country>
            <name>USA</name>
            <state>AL</state>
            <state>TX</state>
            <state>NY</state>
          </country>
          <country>
            <name>India</name>
            <state>AP</state>
            <state>UP</state>
            <state>TN</state>
          </country>
        </root>
    </mx:Model>
</mx:Application>