dimanche 23 novembre 2008

Binding of all attributes of an XML node to a DataGrid

I've wanted to bind all attributes (name and value) to a datagrid (see previous post about NuggViewer and BSP attributes). I'm didn't find an easy way to do it, so I used two "label Functions" (one for the name and another for the value). So, it gives something like:
Data:
<page APPLNAME="ZHRHAP_BSP_CE" PAGEKEY="BODY.DO" PAGENAME="body.do" AUTHOR="PTG76743" CREATEDON="20080708" CHANGEDBY="PTG76743" CHANGEDON="20080708" IMPLCLASS="CL_BSP_HAP_DOCUMENT_COH2" GENDATE="20080708" GENTIME="121613" PAGETYPE="C" CHANGETIME="120955" BROWSER_CACHE="0 " SERVER_CACHE="0 " LAYOUTLANGU="E" VERSION="A" DEVCLASS="$TMP" LANGU="E" DESCRIPT="Body Controller"/>

Flex code:
<mx:DataGrid dataProvider="{LV_XmlBSP_Page.@*}">
<mx:columns>
<mx:DataGridColumn headerText="Name" labelFunction="Lbl_Fction_AttrName" />
<mx:DataGridColumn headerText="Attribute" labelFunction="Lbl_Fction_AttrValue" />
</mx:columns>
</mx:DataGrid>
//------------------------------------------------------------------------------------------------
// Label function to display value and name of XML attributes
//------------------------------------------------------------------------------------------------
private function Lbl_Fction_AttrName(obj_data:XML, obj_dataGridColumn:DataGridColumn):String
{
return obj_data.name();
}

private function Lbl_Fction_AttrValue(obj_data:XML, obj_dataGridColumn:DataGridColumn):String
{
return obj_data.toXMLString();
}

1 commentaire:

  1. Aloe Medication fartonast

    http://www.ncaddtampa.org/ - order prozac

    Side Effects of Prozac
    Signs on the following allergic reactions require emergency medical attention: hives, swelling of the tongue, lips, face, throat, difficulty breathing.
    [url=http://www.ncaddtampa.org/]prozac medication[/url]
    This is to help give the best possible results.
    fluoxetine online

    If you overdose ? Emergency medical attention is required if you think you may have taken an overdose.


    lexapro price

    Lexapro is also known by its generic name Escitalopram.
    [url=http://www.garrisoniowa.com/]lexapro drug[/url]
    If a patient is on any type of monoamine oxidase inhibitor (MAOI), he/she should not take Lexapro.
    http://www.garrisoniowa.com/ - buy lexapro online
    Avoid alcohol while you will be on Lexapro.

    RépondreSupprimer