Regresar   Foros del Web > Diseño de Sitios web > Flash y Actionscript > Flex

El registro es Gratis en Foros del Web
Respuesta
 
Herramientas Buscar en Tema Desplegado
Antiguo 05/05/08, 15:25:15   #1 (permalink)
Sergestux no ha recibido karma de otros usuarios
 
Registrado: ago 2007
Ubicación: Tijuas
Mensajes: 260
Contactar con Sergestux a través de Yahoo
Sergestux is offline  
Cargar valores a CheckBox con un XML remoto

Hola colegas del foro, veran estoy intentado cargar de un archivo XML externo que tiene la estructura siguiente:
Código PHP:
<Conceptos>    
    <
Concepto id="1" descripcion="Primer Concepto" Lun='true' Mar='true' Mier='true' Jue='false' Vie='true' Sab='true' Dom='false'/>
    <
Concepto id="2" descripcion="Segundo Concepto" Lun='false' Mar='false' Mier='true' Jue='false' Vie='true' Sab='false' Dom='false'/>
    <
Concepto id="3" descripcion="Tercer Concepto" Lun='true' Mar='false' Mier='true' Jue='true' Vie='false' Sab='true' Dom='false'/>
</
Conceptos
Donde me he quedado sin poder resolverlo es en la parte de asignarle los valores almacenados en el Xml externo a los checkbox
Código PHP:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="ConceptoXml.send();">
<mx:HTTPService id="ConceptoXml" url="http://localhost/Conceptos.xml" resultFormat="e4x" showBusyCursor="true"/>
<mx:Script>
    <![CDATA[
        import mx.controls.CheckBox;                 
    ]]>
</mx:Script>
    <mx:VBox width="100%" 
           height="100%">
        <mx:DataGrid width="380" height="210" dataProvider="{ConceptoXml.lastResult.Concepto}">
            <mx:columns>
                <mx:DataGridColumn headerText="Concepto" dataField="@descripcion" width="120"/>
                <mx:DataGridColumn headerText="L" dataField="@Lun" editorDataField="@Lun" 
                    rendererIsEditor="true"    itemRenderer="mx.controls.CheckBox"/>
                <mx:DataGridColumn headerText="M" dataField="@Mar" itemRenderer="mx.controls.CheckBox"/>
                <mx:DataGridColumn headerText="M" dataField="@Mier" itemRenderer="mx.controls.CheckBox"/>
                <mx:DataGridColumn headerText="J" dataField="@Jue" itemRenderer="mx.controls.CheckBox"/>
                <mx:DataGridColumn headerText="V" dataField="@Vie" itemRenderer="mx.controls.CheckBox"/>
                <mx:DataGridColumn headerText="S" dataField="@Sab" itemRenderer="mx.controls.CheckBox"/>
                <mx:DataGridColumn headerText="D" dataField="@Dom" itemRenderer="mx.controls.CheckBox"/>
            </mx:columns>
        </mx:DataGrid>
    </mx:VBox>
</mx:Application>
Alguien que pueda ayudarme, le estaría muy agradecido.

P.D.T. El Xml podria modificarlo a otra estructura de ser necesario
__________________
You'll be free, hackers, you'll be free
  Responder Con Cita
Antiguo 06/05/08, 11:37:09   #2 (permalink)
Sergestux no ha recibido karma de otros usuarios
 
Registrado: ago 2007
Ubicación: Tijuas
Mensajes: 260
Contactar con Sergestux a través de Yahoo
Sergestux is offline  
Re: Cargar valores a CheckBox con un XML remoto

Hola veran pude resolver esto de una manera que no muy me gusto, pero funciona.
Aca va el codigo unicamente para los dos primeros dias Lunes (L) y Martes(M)

Código:
                <mx:DataGridColumn headerText="L" dataField="@Lun" rendererIsEditor="true">
                <mx:itemRenderer>
                    <mx:Component>
                        <mx:CheckBox creationComplete="init()">
                    <mx:Script>
                        <![CDATA[                    
                            private var _data:Object;
                            private function init():void
                            {
                                this.addEventListener(MouseEvent.CLICK, update);
                            }
                            [Bindable]
                            override public function get data():Object
                            {
                                return _data;
                            }
                            
                            override public function set data(o:Object):void
                            {
                                _data = o;
                                if(o.@Lun == "true")
                                    this.selected = true;
                                else
                                    this.selected = false;
                                        
                            }
                            private function update(event:MouseEvent):void
                            {
                                if(this.selected)
                                _data.checked = "true";
                                else
                                    _data.checked = "false";        
                            }                                                     
                        ]]>                    
                    </mx:Script>
                    </mx:CheckBox>
                    </mx:Component>
                </mx:itemRenderer>
                </mx:DataGridColumn>                
                                
                <mx:DataGridColumn headerText="M" dataField="@Mar" rendererIsEditor="true">
                <mx:itemRenderer>
                    <mx:Component>
                        <mx:CheckBox creationComplete="init()">
                    <mx:Script>
                        <![CDATA[                    
                            private var _data:Object;
                            private function init():void
                            {
                                this.addEventListener(MouseEvent.CLICK, update);
                            }
                            [Bindable]
                            override public function get data():Object
                            {
                                return _data;
                            }
                            
                            override public function set data(o:Object):void
                            {
                                _data = o;
                                if(o.@Mar == "true")
                                    this.selected = true;
                                else
                                    this.selected = false;
                                        
                            }
                            private function update(event:MouseEvent):void
                            {
                                if(this.selected)
                                _data.checked = "true";
                                else
                                    _data.checked = "false";        
                            }                                                     
                        ]]>                    
                    </mx:Script>
                    </mx:CheckBox>
                    </mx:Component>
                </mx:itemRenderer>
                </mx:DataGridColumn>
Si alguien sabe alguna manera mucho mas optima, por favor que sea tan amable de indicarla
__________________
You'll be free, hackers, you'll be free
  Responder Con Cita
Antiguo 06/05/08, 12:37:42   #3 (permalink)
Sergestux no ha recibido karma de otros usuarios
 
Registrado: ago 2007
Ubicación: Tijuas
Mensajes: 260
Contactar con Sergestux a través de Yahoo
Sergestux is offline  
Re: Cargar valores a CheckBox con un XML remoto

Bueno al final lo he dejado asi para cada dia:
Código PHP:
                <mx:DataGridColumn headerText="L" dataField="@Lun">
                    <
mx:itemRenderer>
                    <
mx:Component>
                        <
mx:CheckBox>
                            <
mx:Script>
                            <![
CDATA[                    
                                
override public function set data(o:Object):void
                                
{
                                    
this.selected Boolean(int(o.@Lun));    //Lo convierto a entero, despues a boleano
                                
}
                            ]]>                    
                            </
mx:Script>
                        </
mx:CheckBox>
                    </
mx:Component>
                </
mx:itemRenderer>
            </
mx:DataGridColumn
Obviamente modifique el xml para que guardara valores de 0 y 1, en vez de falso y verdadero
Código PHP:
<Conceptos>
<
Concepto id="1" descripcion="Primer Concepto" Lun="0" Mar="0" Mier="1" Jue="0" Vie="1" Sab="0" Dom="0"/>
<
Concepto id="2" descripcion="Segundo Concepto" Lun="0" Mar="1" Mier="1" Jue="0" Vie="1" Sab="0" Dom="0"/>
<
Concepto id="3" descripcion="Tercer Concepto" Lun="1" Mar="0" Mier="1" Jue="1" Vie="0" Sab="1" Dom="0"/>
</
Conceptos
__________________
You'll be free, hackers, you'll be free
  Responder Con Cita
Respuesta


Califica este Tema - Cargar valores a CheckBox con un XML remoto.

Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado Califica este Tema
Califica este Tema:

Reglas del foro
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está activado
Las caritas están activado
Código [IMG] está activado
Código HTML está desactivado


Todas las horas son GMT -6. La hora es 23:19:17.

Message Board Statistics

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96