flex: display number of children in datagrid column

146 views Asked by At

I have a XML-file looking like this:

<deelnemers>
<deelnemer id="timka"> <actID>0</actID> <actID>1</actID> </deelnemer>
<deelnemer id="hop">
<actID>0</actID> <actID>1</actID> <actID>3</actID> </deelnemer>
</deelnemers>

I want a dataGrid showing in a column the number of actID's for every person. So far I have a column dat gives the actID's serperated by a ','. How do I get the column to display the total of actID's ?

Here is the code for the column:

<mx:DataGrid id="deelnemersActiviteit" width="130" height="440" dataProvider="{ActiviteitLeiding}">
            <mx:columns>
                <mx:DataGridColumn dataField="actID" editable="false" headerText="Totem" resizable="false" width="100"/>
            </mx:columns>
        </mx:DataGrid>
1

There are 1 answers

0
Christophe Herreman On

You'll have to give the column a label function in which you return the number of actID nodes of the "deelnemer" node. You can leave out the dataField property on your column.

The item parameter of the label function will refer to the "deelnemer" node. You can return the number of actID nodes with:

item.actID.length();