Flex/Flash 4 datagrid literally displays XML
- by Setori
Problem: Flex/Flash4 client (built with FlashBuilder4) displays the xml sent from the server exactly as is - the datagrid keeps the format of the xml. I need the datagrid to parse the input and place the data in the correct rows and columns of the datagrid.
flow: click on a date in the tree and it makes a server request for batch information in xml form. Using a CallResponder I then update the datagrid's dataProvider.
[code]
<fx:Script>
<![CDATA[
import mx.controls.Alert;
[Bindable]public var selectedTreeNode:XML;
public function taskTreeChanged(event:Event):void {
selectedTreeNode=Tree(event.target).selectedItem as XML;
var searchHubId:String = selectedTreeNode.@hub;
var searchDate:String = selectedTreeNode.@lbl;
if((searchHubId == "") || (searchDate == "")){
return;
}
findShipmentBatches(searchDate,searchHubId);
}
protected function findShipmentBatches(searchDate:String, searchHubId:String):void{
findShipmentBatchesResult.token = actWs.findShipmentBatches(searchDate, searchHubId);
}
protected function updateBatchDataGridDP():void{
task_list_dg.dataProvider = findShipmentBatchesResult.lastResult;
}
]]>
</fx:Script>
<fx:Declarations>
<actws:ActWs id="actWs" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
<s:CallResponder id="findShipmentBatchesResult" result="updateBatchDataGridDP()"/>
</fx:Declarations>
<mx:AdvancedDataGrid id="task_list_dg" width="100%" height="95%" paddingLeft="0" paddingTop="0" paddingBottom="0">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="Receiving date" dataField="rd"/>
<mx:AdvancedDataGridColumn headerText="Msg type" dataField="mt"/>
<mx:AdvancedDataGridColumn headerText="SSD" dataField="ssd"/>
<mx:AdvancedDataGridColumn headerText="Shipping site" dataField="sss"/>
<mx:AdvancedDataGridColumn headerText="File name" dataField="fn"/>
<mx:AdvancedDataGridColumn headerText="Batch number" dataField="bn"/>
</mx:columns>
</mx:AdvancedDataGrid>
[/code]
I cannot upload a pic, but this is the xml:
[code]
2010-04-23 16:35:51.0
PRESHIP
2010-02-15 00:00:00.0
100000009
DF-Ocean-PRESHIPSUM-Quanta-PACT-EMEA-Scheduled Ship Date 20100215.csv
10053
[/code]
and the xml is pretty much displayed exactly as is in the datagrid columns...
I would appreciate your assistance.