Flex/Flash 4 datagrid displays raw xml

Posted by Setori on Stack Overflow See other posts from Stack Overflow or by Setori
Published on 2010-04-30T01:45:54Z Indexed on 2010/04/30 4:07 UTC
Read the original article Hit count: 458

Filed under:
|
|
|

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>

//xml example from server
<batches>
    <batch>
        <rd>2010-04-23 16:31:00.0</rd>
        <mt>SC1REVISION01</mt>
        <ssd>2010-02-18 00:00:00.0</ssd>
        <sss>100000009</sss>
        <fn>Revision 1-DF-Ocean-SC1SUM-Quanta-PACT-EMEA-Scheduled Ship Date 20100218.csv</fn>
        <bn>10041</bn>
    </batch>
<batches>

[/code]

and the xml is pretty much displayed exactly as is shown in the example above in the datagrid columns...

I would appreciate your assistance.

© Stack Overflow or respective owner

Related posts about flex4

Related posts about flash