Comunidad de diseño web y desarrollo en internet online

Como llenar un List component

Citar            
MensajeEscrito el 30 Oct 2007 10:25 pm
Hola comunidad.. soy nuevo en el foro.. espero poder ayudar asi como poder ser ayudado..

Alguien sabe como llenar el componente List con un ArrayCollection de la siguiente forma en multiples lineas:

Código :

private var arr:ArrayCollection = new ArrayCollection([
 { name:'gip', dir:'none', col:'azahuj', cp:'54875', oth:'minnj' },
 { name:'gip', dir:'none', col:'azahuj', cp:'54875', oth:'minnj' }
]);
<mx:List dataProvider="{arr}" id="lista" width="766" wordWrap="true" height="236"/>

Por Jack Fiallos

6 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 30 Oct 2007 10:52 pm
mmm, en todo caso, te serviría mas un datagrid, pues el List solo mostraría una columna, mientras que con el DataGrid puedes mostrar mas.
Con List solo te faltaría indicar cual es la columna que se va a mostrar:

Código :

[Bindable] private var arr:ArrayCollection = new ArrayCollection([
 { name:'gip', dir:'none', col:'azahuj', cp:'54875', oth:'minnj' },
 { name:'gip', dir:'none', col:'azahuj', cp:'54875', oth:'minnj' }
]);
<mx:List dataProvider="{arr}" id="lista" width="766" wordWrap="true" height="236" labelField="name"/>


con DataGrid sería algo así:

Código :

[Bindable] private var arr:ArrayCollection = new ArrayCollection([
 { name:'gip', dir:'none', col:'azahuj', cp:'54875', oth:'minnj' },
 { name:'gip', dir:'none', col:'azahuj', cp:'54875', oth:'minnj' }
]);
<mx:DataGrid dataProvider="{arr}">
   <mx:columns>
      <mx:DataGridColumn headerText="Name" dataField="name"/>
      <mx:DataGridColumn headerText="Dir" dataField="dir"/>
      <mx:DataGridColumn headerText="Col" dataField="col"/>
      <mx:DataGridColumn headerText="CP" dataField="cp"/>
      <mx:DataGridColumn headerText="OTH" dataField="oth"/>
   </mx:columns>
</mx:DataGrid>


OJO con el [Bindable], pues con eso, logras que tus varibles creadas en AS, puedan ser accedidas desde el mxml.

Espero que esto te sirva,
Saludos! :wink:

Por master_of_puppetz

Claber

2483 de clabLevel

7 tutoriales
3 articulos

Genero:Masculino   Premio_Secretos

WebDev (Flex + PHP + JS)

firefox
Citar            
MensajeEscrito el 30 Oct 2007 11:19 pm
Wow.. muchas gracias por el [Bindable] no sabia que tenia esa utilidad.. pero en cuanto a tu respuesta.. el muy cierto que el DataGrid me serviria mejor.. pero este componente ordena los datos en columnas.. y yo necesito ordenar los datos en filas, pienso que al final deberia de quedarme algo como:

------------------
gip
none
azahuj
54875
minnj
------------------
gip
none
azahuj
54875
minnj
------------------
...

O no se si exista alguna otra forma de obtener el mismo resultado...

Gracias por la ayuda

Por Jack Fiallos

6 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 31 Oct 2007 07:26 pm
Bueno, por lo visto no fue tan facil mi problema.. pero aqui tengo la respuesta.. quizas se necesiten afinan algunas cosillas pero el funcionamiento es el que buscaba.

Para esto necesite crearme un componente personalizado, al componente list se le escribe el origen del dataprovider y el itemRenderer se le pondra un enlace al componente personalizado. Al final queda algo como esto:

Espero que a alguien le sirva... y ya ven.. despues de mucha lectura y algo de investigación todo se puede..

Código :

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
   <mx:Script>
      <![CDATA[
         import mx.collections.ArrayCollection;
         
         private var arr:ArrayCollection = new ArrayCollection([
            {
               name:'jack',
               dir:'minnj',
               cp:'54875'
            },
            {
               name:'maibomm',
               dir:'none',
               cp:'54875'
            },
            {
               name:'erling',
               dir:'central',
               cp:'54875'
            }
         ]);
            
      ]]>
   </mx:Script>
   <mx:Component id="RenderVW">
      <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="100">
         <mx:Text id="link" styleName="ResultTitle" width="100%" text="{data.name}"/>
         <mx:Text id="description" condenseWhite="true" width="100%" text="{data.dir}" color="#c0c0c0"/>
         <mx:Text id="url" styleName="ResultUrl" text="{data.cp}"/>   
      </mx:VBox>
   </mx:Component>
   <mx:List id="lista" dataProvider="{arr}" width="766" wordWrap="true" height="236" itemRenderer="{RenderVW}" variableRowHeight="true"/>   
</mx:Application>

Por Jack Fiallos

6 de clabLevel



Genero:Masculino  

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.