0 Replies Latest reply on Jul 13, 2006 1:03 PM by Stonyx

    click event for datagrid and cellrender

    Stonyx
      hello;
      i'm really new with FLEX hope somebody can help me (F2B1)
      have 2 questions
      1.- i'm using e4x to make a search on 2 XML(wich i have as database)
      is how do i make the images to appear next to the names (cellrender) and show in a mx:image
      i tried using datagrid.selectedItem.Image, or datagrid.selectedItem.@Image but don-t work

      2.-in my datagrid when click on any name this name will go to a 2nd datagrid so it will act as a undo datagrid

      MXML
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.macromedia.com/2005/mxml" xmlns:local="*"
      creationComplete="cargarDatos(),cargarDatos2(),srv.send()"
      viewSourceURL="srcview/index.html" layout="vertical"
      backgroundColor="#800000" currentState="buscador">
      <mx:Style source="main.css"/>
      <mx:Script>

      <![CDATA[

      public function cargarDatos():void
      {
      srv.url = "datos.xml";
      srv.send();
      }
      public function cargarDatos2():void
      {
      srv.url = "datos2.xml";
      srv.send();
      }
      private function filtrar(item:Object):Boolean
      {
      return item.name.match(new RegExp("^" + inputText.text, "i\*\t\s[']"));
      }
      ]]>
      </mx:Script>
      <mx:HTTPService id="srv" resultFormat="e4x" useProxy="false"/>


      <mx:XMLListCollection id="xlc"
      source="{srv.result.*}"
      filterFunction="filtrar" />


      <mx:TitleWindow width="968" height="643"
      layout="absolute" title="Diccionario Enciclopédico Universitario"
      fontSize="16" fontFamily="Arial" id="titlewindow1">
      <mx:layoutConstraints>
      <mx:Anchor right="25" bottom="80"/>
      </mx:layoutConstraints>

      <mx:Canvas backgroundColor="#800000" id="multimedia" cornerRadius="0">
      <mx:layoutConstraints>
      <mx:Anchor left="5" top="5" bottom="36" right="26"/>
      </mx:layoutConstraints>
      <mx:DataGrid dataProvider="{xlc}"
      editable="false" width="168" id="datagrid" scroll="true"
      showHeaders="true" fontSize="12" height="528" cornerRadius="10">
      <mx:layoutConstraints>
      <mx:Anchor left="4" top="72"/>
      </mx:layoutConstraints>
      <mx:columns>
      <mx:Array>
      <mx:DataGridColumn columnName="name"/>
      <mx:DataGridColumn columnName="image" textAlign="justify" cellRenderer="ImageCellRenderer"/>
      </mx:Array>
      </mx:columns>
      </mx:DataGrid>
      <mx:Panel height="423" width="459" headerHeight="18">
      <mx:layoutConstraints>
      <mx:Anchor left="180" bottom="64"/>
      </mx:layoutConstraints>
      <mx:TextArea id="areaDeTexto" width="438" height="400" textAlign="justify"
      wordWrap="true" editable="false" htmlText="{datagrid.selectedItem.desc}"
      backgroundImage="FONDOS/escudo.jpg" backgroundSize="100%">
      <mx:layoutConstraints>
      <mx:Anchor horizontalCenter="-10"/>
      </mx:layoutConstraints>
      </mx:TextArea>
      </mx:Panel>
      <mx:TextInput id="inputText" width="170"
      change="xlc.refresh()" text="a" backgroundColor="#f0eff1" fontSize="12"
      toolTip="Escriba el nombre de su busqueda" cornerRadius="6">
      <mx:layoutConstraints>
      <mx:Anchor bottom="545" left="4"/>
      </mx:layoutConstraints>
      </mx:TextInput>
      <mx:Button height="32" width="42" cornerRadius="6" toolTip="Esto somos" x="321"
      click="cargarDatos()" y="29">
      </mx:Button>
      <mx:Button height="32" width="42" cornerRadius="6" toolTip="Semblanzas"
      x="369"
      click="cargarDatos2()" y="29">
      </mx:Button>
      <mx:Button height="32" width="42" cornerRadius="6" toolTip="Multimedia"
      x="454" y="29">
      </mx:Button>
      <mx:Button height="32" width="42" cornerRadius="6" toolTip="Fotos"
      x="502" y="29">
      </mx:Button>
      <mx:Button height="32" width="42" cornerRadius="6" toolTip="Organigramas"
      x="549" y="29">
      </mx:Button>
      <mx:Button height="32" width="42" cornerRadius="6" toolTip="Gráficas"
      x="597" y="29">
      </mx:Button>
      <mx:Button width="40" height="32" cornerRadius="6" id="ujat"
      toolTip="www.UJAT.mx"
      click="getURL(' http://www.ujat.mx', '_blank')" x="892" y="29">
      </mx:Button>
      <mx:List x="180" y="559" width="220" height="41" backgroundColor="#ffffff"
      dataProvider="{datagrid.selectedItem.video.@id}" alpha="0.5" cornerRadius="0"></mx:List>
      <mx:Label x="180" y="538" text="Videos" width="130"
      fontWeight="bold" color="#ffffff" fontSize="12"/>
      <mx:List x="419" y="559" width="220" height="41" backgroundColor="#ffffff"
      dataProvider="{datagrid.selectedItem.audio.@id}" alpha="0.5" cornerRadius="0"></mx:List>
      <mx:Label x="419" y="538" text="Audios" width="130"
      fontWeight="bold" color="#ffffff" fontSize="12"/>
      <mx:TextArea x="180" width="753"
      height="46" fontWeight="bold"
      text="{datagrid.selectedItem.name}"
      fontSize="18" alpha=".5" color="#ffffff" fontFamily="Arial" wordWrap="true" editable="false"
      cornerRadius="8">
      <mx:layoutConstraints>
      <mx:Anchor top="65"/>
      </mx:layoutConstraints>
      </mx:TextArea>
      </mx:Canvas>
      </mx:TitleWindow>
      </mx:Application>

      XMLs are something like this
      <catalog>
      <book>
      <name>Abdo</name>
      <desc>blablablablablablablablablablablablablablablalbabla</desc>
      <image>FOTOS/Abdo.jpg</image>
      </book>
      </catalog>