Comunidad de diseño web y desarrollo en internet online

datagrid y combobox en flex

Citar            
MensajeEscrito el 09 Ene 2009 01:25 am
hola espero q me puedan ayudar lo q necesito poner dentro de un datagrid varios combo box pero necesito q los datos de ese combobox sean de un array distinto al del datagrid

como en el codigo anterior q los datos del datagrid son de "arrColl" y los datos del combobox son del "arrcombo"
quien me puede corregir o decir como hago aquello

saludos y espero q me puedan responder gracias

Código :

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/05/12/using-a-numericstepper-control-as-an-item-editor-for-a-datagrid-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">
            <mx:ArrayCollection id="arrcombo">
        <mx:source>
            <mx:Array>
                <mx:Object label="1"/>
                <mx:Object label="2"/>
                <mx:Object label="3"/>
                <mx:Object label="4"/>
                <mx:Object label="5"/>
                <mx:Object label="6"/>
                <mx:Object label="7"/>
                <mx:Object label="8"/>
                <mx:Object label="9"/>
            </mx:Array>
        </mx:source>
    </mx:ArrayCollection>

    <mx:ArrayCollection id="arrColl">
        <mx:source>
            <mx:Array>
                <mx:Object label="Student A" score="8" />
                <mx:Object label="Student B" score="4" />
                <mx:Object label="Student C" score="7" />
                <mx:Object label="Student D" score="8" />
                <mx:Object label="Student E" score="2" />
                <mx:Object label="Student F" score="6" />
                <mx:Object label="Student G" score="7" />
                <mx:Object label="Student H" score="7" />
                <mx:Object label="Student I" score="9" />
                <mx:Object label="Student J" score="8" />
                <mx:Object label="Student K" score="4" />
                <mx:Object label="Student L" score="7" />
            </mx:Array>
        </mx:source>
    </mx:ArrayCollection>

    <mx:DataGrid id="dataGrid"
            dataProvider="{arrColl}"
            editable="true"
            rowCount="8">
        <mx:columns>
            <mx:DataGridColumn dataField="label"
                    editable="false" />
            <mx:DataGridColumn dataField="score"
                    editable="true"
                    itemEditor="mx.controls.ComboBox"
                    editorDataField="{arrcombo}" />
        </mx:columns>
    </mx:DataGrid>
   <mx:ComboBox dataProvider="{arrcombo}"/>
</mx:Application>

Por anikilatorbeta

42 de clabLevel



 

firefox
Citar            
MensajeEscrito el 09 Ene 2009 01:57 am
e encontrado la solucion jejeje la dejo aqui abajo
habia q creer un classfactory con el combobox y ahy ponerle el data provider con el otro array

Código :

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/05/12/using-a-numericstepper-control-as-an-item-editor-for-a-datagrid-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white" initialize="init();">
        <mx:Script>
           <![CDATA[
              [Bindable]
      private var combofac:ClassFactory;
      private function init():void{
         combofac=new ClassFactory(ComboBox);
         combofac.properties={dataProvider:arrcombo};
      }
           ]]>
        </mx:Script>
            <mx:ArrayCollection id="arrcombo">
        <mx:source>
            <mx:Array>
                <mx:Object label="1"/>
                <mx:Object label="2"/>
                <mx:Object label="3"/>
                <mx:Object label="4"/>
                <mx:Object label="5"/>
                <mx:Object label="6"/>
                <mx:Object label="7"/>
                <mx:Object label="8"/>
                <mx:Object label="9"/>
            </mx:Array>
        </mx:source>
    </mx:ArrayCollection>

    <mx:ArrayCollection id="arrColl">
        <mx:source>
            <mx:Array>
                <mx:Object label="Student A" score="8" />
                <mx:Object label="Student B" score="4" />
                <mx:Object label="Student C" score="7" />
                <mx:Object label="Student D" score="8" />
                <mx:Object label="Student E" score="2" />
                <mx:Object label="Student F" score="6" />
                <mx:Object label="Student G" score="7" />
                <mx:Object label="Student H" score="7" />
                <mx:Object label="Student I" score="9" />
                <mx:Object label="Student J" score="8" />
                <mx:Object label="Student K" score="4" />
                <mx:Object label="Student L" score="7" />
            </mx:Array>
        </mx:source>
    </mx:ArrayCollection>

    <mx:DataGrid id="dataGrid"
            dataProvider="{arrColl}"
            editable="true"
            rowCount="8">
        <mx:columns>
            <mx:DataGridColumn dataField="label"
                    editable="false" />
            <mx:DataGridColumn dataField="score"
                    editable="true"
                    itemEditor="{combofac}"/>
        </mx:columns>
    </mx:DataGrid>
   <mx:ComboBox dataProvider="{arrcombo}"/>
</mx:Application>

Por anikilatorbeta

42 de clabLevel



 

firefox
Citar            
MensajeEscrito el 01 Dic 2009 07:01 pm
no sabes como hago lo mismo, pero cambiar el arrcombo del combofac por xml de un HTTPService?
como quien dice:

Código ActionScript :

combofac.properties={dataProvider:datos.lastResult.datos.dato};

Por ferckham07

12 de clabLevel



Genero:Masculino  

Software Developer

chrome
Citar            
MensajeEscrito el 01 Dic 2009 07:17 pm
si lo se, es lo mismo en vez del dataProvider linkiarlo a un arreglo lo linkeas a un xml
saludos

Por anikilatorbeta

42 de clabLevel



 

mozilla
Citar            
MensajeEscrito el 01 Dic 2009 08:11 pm
como lo linkeo a un xml?
el codigo que escribi, no me funciono

Por ferckham07

12 de clabLevel



Genero:Masculino  

Software Developer

chrome
Citar            
MensajeEscrito el 01 Dic 2009 08:12 pm
por cierto, gracias por responder!

Por ferckham07

12 de clabLevel



Genero:Masculino  

Software Developer

chrome
Citar            
MensajeEscrito el 02 Dic 2009 12:20 am
jejejej q tonto yop me falto algo decirte esque ahy q agregar una nueva linea de codigo
combofac.properties={labelField:"nombre"};
en donde ahy se pone el nombre del nodo q quieres mostrar
saludo

Por anikilatorbeta

42 de clabLevel



 

mozilla
Citar            
MensajeEscrito el 02 Dic 2009 09:36 am
ok, lo pruebo
igual gracias

Por ferckham07

12 de clabLevel



Genero:Masculino  

Software Developer

chrome
Citar            
MensajeEscrito el 07 Dic 2009 08:33 pm
me falta acomodar unas cosillas, pero ya esta casi listo
muchas gracias!!

por cierto para la parte de:

Código ActionScript :

combofac=new ClassFactory(ComboBox);


no se si lo sepas(me imagino que si) pero puedes evitar crear el combobox de abajo si en vez de eso utilizas:

Código ActionScript :

combofac=new ClassFactory(mx.controls.ComboBox);


de nuevo MUCHAS GRACIAS, saludos

Por ferckham07

12 de clabLevel



Genero:Masculino  

Software Developer

chrome
Citar            
MensajeEscrito el 21 Dic 2009 06:48 pm
sigo sin poder hacer lo que quiero
anikilatorbeta no sabes como hacerle en esto:
http://foros.cristalab.com/duda-combobox-dataprovider-t81839/

esta al final del post
gracias, saludos

Por ferckham07

12 de clabLevel



Genero:Masculino  

Software Developer

chrome
Citar            
MensajeEscrito el 05 Ene 2010 05:46 pm
ya lo resolvi, muchas gracias

es como tu decias, solo que yo agregaba la linea y era solamente

Código ActionScript :

combofac.properties={dataProvider:datos.lastResult.datos.dato, labelField:"nodo"};


de nuevo muchas gracias

Por ferckham07

12 de clabLevel



Genero:Masculino  

Software Developer

chrome

 

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