3 Replies Latest reply on Sep 17, 2009 2:27 AM by lerooooogk

    Refresh a list when a mxml is opened

    lerooooogk Level 1

      Hi all,

       

      I have two mxml. In the first, i've a datagrid that is correctly populated and it has some headercolumns (for example: name).

       

      In the second mxml, I want to show the user all the names  in the datagrid.

       

      To show the names I use a list. That list is populated when the mxml creation is completed (event 'creationCompleted'). The problem is when the datagrid change so the new names are not shown to user.

       

      Is there any way, event or similar wich I can refresh the list when the second mxml is opened?

       

      Thanks in advance!

        • 1. Re: Refresh a list when a mxml is opened
          _Natasha_ Level 4

          Hi,

          yes.

          This method called data binding

           

          See mx.binding.utils.BindingUtils for more info

          1 person found this helpful
          • 2. Re: Refresh a list when a mxml is opened
            flexprad09 Level 2

            Hi lerogke,

             

            You can use dataChange property of DAtagrid to call a function which should refresh dataprovider of your List.
            This is From what i can understand from your Post. But i am not sure  on which event you are opening your second MXML which contains list.
            I hope this helps.

             

            If this post answers your question or helps, please mark it as such.

             

            Cheers,

            Prad.

            1 person found this helpful
            • 3. Re: Refresh a list when a mxml is opened
              lerooooogk Level 1

              Hi, thanks for your answers!

               

              DataBinding is very "hard" for my app because I really haved lot of mxml.

               

              I tried to use dataChange property but nothing happens.

               

              This is my actual code:

               

                    Datagrid in main.mxml

              <comp:ColoredDataGrid id="dg_events" width="100%" height="100%"
                                       dataProvider="{eventList.eventCollection}"
                                       rowColorFunction="getRowColor"
                                       dataChange="dataChangeDg()">
                                       <comp:columns>
                                            <mx:DataGridColumn headerText="Nombre de evento" width="150"
                                                 dataField="name"/>
                                            <mx:DataGridColumn headerText="ID" width="40"
                                                 dataField="eventId"/>
                                            <mx:DataGridColumn headerText="Propietario" width="120"
                                                 dataField="owner"/>
                                            <mx:DataGridColumn headerText="Fecha" width="70"
                                                 dataField="date"/>
                                            <mx:DataGridColumn headerText="Hora" width="55"
                                                 dataField="time"/>
                                            <!-- <mx:DataGridColumn headerText="N. Parámetros" width="100"
                                                 dataField="numParams"/> -->
                                            <mx:DataGridColumn headerText="Parámetros"
                                                 labelFunction="eventList.getParams"/>
                                            <!--<mx:DataGridColumn headerText="Archivo" width="40"
                                                 dataField="numFile"/>-->
                                       </comp:columns>
                                  </comp:ColoredDataGrid>
              

               

              And now filterParam.mxml (this is where I want to refresh the list). I paste a bit of code:

               

              <?xml version="1.0" encoding="utf-8"?>
              <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="comp.*"
                         creationComplete="load()"
                         dataChange="load()">
              
                        //Activamos panel de filtrado por parámetros y cargamos valores                    
                        public function load():void{
                             panel.percentHeight = 100;                              //Ajustamos tamaño
                             
                             eventsArr = new Array();
                             eventsArr = eventList.categories_events();          //Obtenemos listado de eventos
                             eventsArr.push('---Todos---');                         //Añadimos etiqueta todos para el filtrador
                             eventsArr.sort(1);                                        //Organizamos alfabéticamente
                                                      
                             owners = eventList.categories_owners();               //Obtenemos objetos propietarios
                             owners.push('---Todos---');
                             owners.sort(1);
                             
                             categories = eventList.categories_params();          //Obtenemos todos los parametros
                             categories.sort(1);
                             
                             matchFilter = new MatchFilter(dg);                    //Herramientas de filtrado
                                            
                        }
              
              <mx:VBox>                    
                                            <mx:List id="nameList" dataProvider="{eventsArr}" width="200" height="200"
                                                  doubleClick="nameEv = nameList.selectedItem.toString();"/>
                                            <mx:HBox width="100%">
                                                 <mx:Spacer width="100%"/>
                                                 <mx:Image source="@Embed('/assets/images/system/add.png')" click="addEvent()"
                                                               toolTip="Bla bla bla bla"/>     
                                            </mx:HBox>                              
                                       </mx:VBox>
              

               

              Thanks for your answers!