Ciao a tutti.
Ho qualche problema nel popolare un datagrid.
il mio codice:
codice:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="600" height="500" viewSourceURL="/form_1/index.html">
<mx:Script><![CDATA[
import mx.controls.Alert;
import flash.events.IOErrorEvent;
private function myEventHandler(event:Event):void {
box1.visible=true;
}
public function caricamentoxml(event:Event):void {
var caricamento:URLLoader = new URLLoader();
var filecaricato:URLRequest=new URLRequest("db_xml_prodotti_short.xml");
caricamento.addEventListener(Event.COMPLETE,gestionedati);
try {
caricamento.load(filecaricato);
} catch(e:Error) {
risultato.text="caricamento non riuscito";
}
}
private function gestionedati(event:Event) {
var principale:XML=new XML(event.target.data);
var scheda_prodotto:XMLList=principale.row.products_model;
//risultato.text="caricato "+scheda_prodotto.length();
for (var i:uint=0;i<=scheda_prodotto.length();i++) {
risultato.text=scheda_prodotto.children();
}
}
]]></mx:Script>
<mx:Button x="27" y="10" label="bottone_1" click="box1.visible=false" />
<mx:Button x="27" y="61" label="bottone_2" click="myEventHandler(event)"/>
<mx:Button x="27" y="100" label="bottone_3" click="caricamentoxml(event)"/>
<mx:TextArea x="146" y="10.95" id="risultato" width="230" height="97"/>
<mx:Panel x="10" y="146" width="580" height="344" layout="absolute" title="Box interrogazione" id="box1">
<mx:DataGrid x="93" y="37" width="392" height="257" dataProvider="scheda_prodotto">
<mx:columns>
<mx:DataGridColumn headerText="Codice prodotto" dataField="risultato"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</mx:Application>
Come faccio?
cos'è il dataprovider? e il dataFields?
Grazie,
Ale