Search code examples
databaseapache-flexcomboboxlabelfield

Possible to have more then one labelField in Flex?


I have a combo box that is currently getting its information from a database this seems to be working fine.

Now I would like to have content from two fields displaying in the combo box at once. Say First Name & Last Name

I've added the information to the query fine but the data displayed in the combo box seems to be controlled by the labelField property and it seems to only allow one variable at a time. So it will either display First Name or Last Name but not both at once.

Does anyone know how to do this?

THANKS!

here's bit of my code

        private function NameData():void { //NAME DATA
        var stmt:SQLStatement = new SQLStatement();
        stmt.sqlConnection = sqlConn;
        stmt.text = "SELECT person_fname,person_lname FROM tbl_person ORDER BY person_fname ASC";
        stmt.execute();
        var result:SQLResult = stmt.getResult();
        acName = new ArrayCollection(result.data);
    }

.

    <mx:ComboBox id="picknameInput" x="120" y="202" width="170" labelField="person_fname" dataProvider="{acName}" prompt="- Select Name -"></mx:ComboBox>

Solution

  • You're going to want to use the lableFunction property and have it return the two fields tied together. Here's and Example that should get you started.