6 Replies Latest reply on Feb 10, 2017 9:26 AM by jlara@ediciones-sm.com.mx

    Display data from mysql database in a dropdownlist

    jlara@ediciones-sm.com.mx

      hello

       

      I'm new in this topic of flex and I'm trying to take database information for display on a dropdownlist but I can not make that information is displayed.

      I think I need to store the result in a variable to be shown and no longer do alguin can help me?

      below I show the code I'm utilizadno to display the information in a datagrid and that it would show a dropdownlist.

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

          xmlns:s="library://ns.adobe.com/flex/spark"

          xmlns:mx="library://ns.adobe.com/flex/mx"

          xmlns:datagrilla="services.datagrilla.*"

       

          minWidth="955" minHeight="600" xmlns:conexion="services.conexion.*">

        <fx:Script>

        <![CDATA[

        import mx.collections.ArrayCollection;

        import mx.collections.ArrayList;

        import mx.controls.Alert;

        import mx.events.FlexEvent;

       

           private var DB:ArrayCollection;

       

           protected function dropdownlist_creationCompleteHandler(event:FlexEvent):void

        {

        traerDatosResult.token = conexion.traerDatos();

        }

       

       

        protected function dataGrid_creationCompleteHandler(event:FlexEvent):void

        {

        traerDatosResult.token = conexion.traerDatos();

        }

       

       

        ]]>

        </fx:Script>

        <fx:Declarations>

        <s:CallResponder id="traerDatosResult"/>

        <conexion:Conexion id="conexion"

          fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"

          showBusyCursor="true"/>

        <!-- Place non-visual elements (e.g., services, value objects) here -->

        </fx:Declarations>

        <s:DataGrid id="dataGrid" x="31" y="24" width="231"

        creationComplete="dataGrid_creationCompleteHandler(event)" requestedRowCount="4">

        <s:columns>

        <s:ArrayList>

        <s:GridColumn dataField="type" headerText="type"></s:GridColumn>

        <s:GridColumn dataField="id" headerText="id"></s:GridColumn>

        </s:ArrayList>

        </s:columns>

       

        <s:typicalItem>

        <fx:Object cod="cod1" nombre="nombre1"></fx:Object>

        </s:typicalItem>

       

        <s:AsyncListView list="{traerDatosResult.lastResult}"/>

       

        </s:DataGrid>

       

      <s:HGroup>

        <s:Group id="horizontalPanel1">

       

        <s:layout>

        <s:HorizontalLayout paddingLeft="250" paddingRight="10" paddingTop="90" paddingBottom="10" />

        </s:layout>

       

        <s:DropDownList id="list1" width="100%" dataProvider="{} type" labelField="label"

        prompt="Seleccionar"/>

       

        </s:Group>

        </s:HGroup>

       

      </s:Application>

       

       

      Thank you.