2 Replies Latest reply on Feb 1, 2010 7:33 AM by felix.rivas

    Problem with itemRenderer

    felix.rivas

      I tell them I have a datagrid in which I  have a button that allows me to
      edit the data.
      The idea is that my ArrayCollection dare to weigh the
      parameter enabled (true or false) to  the button.

       

      This is  the code I'm using:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application  xmlns:mx="http://www.adobe.com/2006/mxml
      layout="absolute" initialize="initApp();">
                <mx:Script>
                       <![CDATA[
                                import mx.messaging.AbstractConsumer;
                                import mx.collections.ArrayCollection;

                               [Bindable]
                               private var  _data:ArrayCollection = new ArrayCollection();

                               private function initApp():void
                               { 
                                       _data.addItem({
                                                numReg:01,
                                                dateIn:"28/01/2010",
                                                dateEnd:"28/01/2010",
                                                dateProg:"29/01/2010",
                                                timeProg:"4:59 pm",
                                                status:"Pendiente",
                                                btn_dg:true
                                               });

                                       _data.addItem({
                                                numReg:01,
                                                dateIn:"28/01/2010",
                                                dateEnd:"28/01/2010",
                                                dateProg:"29/01/2010",
                                                timeProg:"4:59 pm",
                                                status:"Error"
                                               });

                                       _data.addItem({
                                                numReg:01,
                                                dateIn:"28/01/2010",
                                                dateEnd:"28/01/2010",
                                                dateProg:"29/01/2010",
                                                timeProg:"4:59 pm",
                                                status:"Finalizado"
                                               });
                               }

                              public  function onEdit(e:Event):void

       

                              {

       

                                       myDG.editable=true;

       

                               }

       

                      ]]>

       

              </mx:Script>

       

               <mx:DataGrid id="myDG" editable="false" dataProvider="{_data}">

       

                      <mx:columns>

       

                               <mx:DataGridColumn headerText="Nro Registro" dataField="numReg"

       

      editable="false"/>

       

                              <mx:DataGridColumn  headerText="Fecha Inicio" dataField="dateIn"/>

       

                               <mx:DataGridColumn headerText="Fecha Fin"  dataField="dateEnd"/>

       

                               <mx:DataGridColumn headerText="Fecha Programada"

       

      dataField="dateProg"/>

       

                               <mx:DataGridColumn headerText="Hora Programada"

       

      dataField="timeProg"/>

       

                               <mx:DataGridColumn headerText="Estatus" dataField="status"

       

      editable="false"/>

       

                              <mx:DataGridColumn  headerText="" dataField="btn_dg"

       

      editable="false">

       

                                       <mx:itemRenderer>

       

                                               <mx:Component>

       

                                                       <mx:Button label="Editar"  click="outerDocument.onEdit

       

      (data.btn_dg)"  enabled="{data.btn_dg}"/>

       

                                               </mx:Component>

       

                                       </mx:itemRenderer>

       

                               </mx:DataGridColumn>

       

                      </mx:columns>

       

              </mx:DataGrid>

       

      </mx:Application>

       

       

      And this  is the error that gives me:

      TypeError: Error #1034: Type Coercion failed: cannot convert true to
      flash.events.Event.
               at TestForo_inlineComponent1/
      ___TestForo_inlineComponent1_Button1_click()[E:\Tutoriales\AIR for
      Flex Developers\Exercise Files\ExtraData\src\TestForo.mxml:61]

       

      Anyone have  any ideas?!!!