Comunidad de diseño web y desarrollo en internet online

explicacion code

Citar            
MensajeEscrito el 02 Dic 2012 03:24 am
for(var i:Number=0; i<myCombo.length; i++){
if(myCombo.getItemAt(i).label==loquesea){
myCombo.selectedIndex = i
break;
}
}
encontre este codigo para combobox modificacion seleccion

me gustaria saber
getItemAt(i)=esto es por defecto o es algun elemnto de mi codigo?
label= aquee elemnto devo llamar ay?
loquesea que devo coocar numeros?? porke mi combo tiene int 1 2 ect.

Por jmancilla

13 de clabLevel



 

chrome
Citar            
MensajeEscrito el 02 Dic 2012 12:52 pm
¿En base a que quieres seleccionar tu combo? Si tienes los labels M y F por ejemplo, y quieres seleccionar F, antes pones

var loquesea:String = "F"

Y te seleccionará F.

Jorge

PD: Media pila para escribir, no cobramos por palabra, no penalizamos escribir palabras completas, si es sin errores de ortografía suma 2

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 02 Dic 2012 03:12 pm
Bueno Resulta que yo tengo un dataGrid con datos como codigo nombre apellido y sexo
sexo = clave foranea de otra tabla que trae consigo masculino y femenino y lo que yo quiero es que al seleccionar una fila en el datagrid presione mi boton modificar aparesca el valor de sexo cargado en mi combobox del formulario modificar que ya tiene dataprovider sexo .

Disculpen las molestias es que soy nuevo en esto y es un proyecto final de año.

saludos!

Por jmancilla

13 de clabLevel



 

chrome
Citar            
MensajeEscrito el 02 Dic 2012 03:56 pm
¿Como está identificado en el dataprovider? Si es F y M, pues puedes hardcodear el combo con esos valores y usar lo que te puse antes ... los principios son simples, luego lo tienes que adaptar a tu contexto

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 02 Dic 2012 07:23 pm
Claro entiendo lo del f y m pero tengo otro combobox que es colegio que viene de otra tabla con los nombres de colegios entonces seria mucho trabajo rellenar mi combobox con los datos de la otra tabla.

mi dataprovider de sexo es sexoService.lastresult de flash builder que trabaja con flex 4 .

Por jmancilla

13 de clabLevel



 

chrome
Citar            
MensajeEscrito el 02 Dic 2012 07:30 pm
este es el codigo de mi pagina central donde esta mi datagrid y el otro codigo es donde esta mi formulario modificar que lo llamo atravez de popup.

Código Flex :

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" 
            xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:pruebasflash1service="services.pruebasflash1service.*">
   <fx:Script>
      <![CDATA[
         import mx.collections.ArrayCollection;
         import mx.containers.TitleWindow;
         import mx.controls.Alert;
         import mx.core.IFlexDisplayObject;
         import mx.events.CloseEvent;
         import mx.events.FlexEvent;
         import mx.events.ItemClickEvent;
         import mx.managers.PopUpManager;
         
   
         
         import spark.components.ComboBox;
         
   
   
         
         protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
         {
            getAllPruebas_flash1Result.token = pruebasflash1Service.getAllPruebas_flash1();
         }
         
         //Variables para busqueda
         //funcion busqueda
         
         private var firstTime:Boolean = true;
         
         private function filter():void {
            getAllPruebas_flash1Result.lastResult.filterFunction = filterMyArrayCollection;
            getAllPruebas_flash1Result.lastResult.refresh();
         }
         
         private function filterMyArrayCollection(item:Object):Boolean {
            var searchString:String = busqueda.text.toLowerCase();
            var itemName:String = (item.nombre as String).toLowerCase();
            return itemName.indexOf(searchString) > -1;
         }
         
         //dentro de busqueda input clear valor defecto "serach...."
         private function clearMyTextInput():void {
            
            if (firstTime == true )
            {
               busqueda.text = "";
               firstTime = false;
            }
         }
         
         //Fin funcion busqueda
         
         //popup agregar
         
         protected function button1_clickHandler(event:MouseEvent):void
         {
            /*   currentState = "uno";
            PopUpManager.addPopUp(olas, this, true);
            PopUpManager.centerPopUp(olas);
            */       
            var sexo:ingresar=new ingresar(); 
            PopUpManager.addPopUp(sexo, this, true); 
            PopUpManager.centerPopUp(sexo);
            //   agrega.addEventListener(CloseEvent.CLOSE, titleWindow_close);
         }
         /*private function titleWindow_close(evt:CloseEvent):void {
         PopUpManager.removePopUp(this);
         }*/
         //FIN POPUP AGREGAR
         
         //variables del modificar
         
         public var editNameWindow:IFlexDisplayObject;
         
         public var myPopUp:modificar;
         
         
         
         public function showPopUp(event:MouseEvent):void{
            
            // show the popup
            editNameWindow=PopUpManager.createPopUp(this, modificar, true);
            
            // cast to a nameEditorPopup
            myPopUp = modificar(editNameWindow);   
            
            
            
            
            // pass the popUp my DataGrid Item
            myPopUp.DataGridName=dataGrid.selectedItem;
            //   myPopUp=getAllPruebas_flashResult.lastResult ;
            myPopUp.DataGridNameAC=getAllPruebas_flash1Result.lastResult;
            
         //    select('1');
            
         }
         /*#########################################################################
         Fin Modificar
         */
      
   /*      public function select(key:String):void{
            for (var i:int=0; i< .length; i++) {
               var item:String = SexoService[i];    
               if(item == key) {
                  combo.comboBox.selectedIndex = i;
                  break;
               }
            }
         }  
         
         */
         
      ]]>
   </fx:Script>
   <fx:Declarations>
      <s:CallResponder id="getAllPruebas_flash1Result"/>
      <pruebasflash1service:Pruebasflash1Service id="pruebasflash1Service" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
   </fx:Declarations>
   <mx:DataGrid x="61" y="90" id="dataGrid"   creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllPruebas_flash1Result.lastResult}">
      <mx:columns>
         <mx:DataGridColumn headerText="codigo" dataField="codigo"/>
         <mx:DataGridColumn headerText="nombre" dataField="nombre"/>
         <mx:DataGridColumn headerText="apellido" dataField="apellido"/>
         <mx:DataGridColumn headerText="sexo" dataField="sexo"/>
      </mx:columns>
   </mx:DataGrid>
   <s:TextInput x="61" y="45" width="176" id="busqueda" change="filter()"  focusIn="clearMyTextInput()" text="Buscar/nombre" enabled="true"/>
   <s:Button x="262" y="46" label="Buscar"/>
   <s:Button x="61" y="272" label="Ingresar" click="button1_clickHandler(event)"/>
   <s:Button x="139" y="272" label="Modificar" click="showPopUp(event)"/>
   <s:Button x="217" y="272" label="Eliminar"/>
   
   
</s:Application>



Código Flex :

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" width="358" height="300" xmlns:valueObjects="valueObjects.*" xmlns:sexoservice="services.sexoservice.*">
   
   <fx:Script>
      <![CDATA[
         import mx.collections.ArrayCollection;
         import mx.containers.TitleWindow;
         import mx.controls.Alert;
         import mx.events.FlexEvent;
         import mx.managers.PopUpManager;

         [Bindable] public var DataGridName:Object;
         [Bindable] public var DataGridNameAC:Menu_Principal_Combobox;
         
         
         
         private function centerWindow():void {
            
            PopUpManager.centerPopUp(this);
            
         }
         
         private function closeWindow():void{
            
            PopUpManager.removePopUp(this);
         }
   
         

         protected function combo_creationCompleteHandler(event:FlexEvent):void
         {
            getAllSexoResult.token = sexoService.getAllSexo();
         }
         
         private function saveName():void{
            
            //   closeWindow();
            
            
            
            
            // update the name
            DataGridName.codigo = codigoTextInput.text;
            DataGridName.nombre = nombreTextInput.text;
            DataGridName.apellido = apellidoTextInput.text;
         //   DataGridName.sexo = getAllSexoResult.lastResult(comboBox.selectedItem.sexo());
   
            closeWindow();
         }
        
         

         protected function comboBox_creationCompleteHandler(event:FlexEvent):void
         {
            getAllSexoResult2.token = sexoService.getAllSexo();
         }
         private function changeCboMateria(e:Event):void {
            
         }
         
      ]]>
   </fx:Script>
   
   <fx:Declarations>
      <valueObjects:Pruebas_flash1 id="pruebas_flash1"/>
      <s:CallResponder id="getAllSexoResult"/>
      <sexoservice:SexoService id="sexoService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
      <s:CallResponder id="getAllSexoResult2"/>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
   </fx:Declarations>
   <s:TitleWindow x="33" y="9" width="292" height="259" title="Modificar Datos">
      <mx:Form defaultButton="{button}" x="42" y="17" height="173">
         <mx:FormItem label="Codigo">
            <s:TextInput id="codigoTextInput" text="{DataGridName.codigo}"/>
         </mx:FormItem>
         <mx:FormItem label="Nombre">
            <s:TextInput id="nombreTextInput" text="{DataGridName.nombre}"/>
         </mx:FormItem>
         <mx:FormItem label="Apellido">
            <s:TextInput id="apellidoTextInput" text="{DataGridName.apellido}"/>
         </mx:FormItem>
   
         <s:Button id="button" label="cargar" />
         <mx:FormItem label="Label">
            <s:ComboBox id="comboBox1" creationComplete="comboBox_creationCompleteHandler(event)"  labelField="cod_sexo"  enabled="true">
               <s:AsyncListView list="{getAllSexoResult2.lastResult}"/>
            </s:ComboBox>
         </mx:FormItem>
      </mx:Form>
   </s:TitleWindow>
</s:Group>

Por jmancilla

13 de clabLevel



 

chrome
Citar            
MensajeEscrito el 04 Dic 2012 01:16 pm
Encontre la solucion ! a mi problema!
Tema cerrado.

Por jmancilla

13 de clabLevel



 

chrome

 

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