tags:

views:

297

answers:

2

Back again with another Flex question. I have an XML structure like...

<Student>
  <Name>X</Name>
  <Age>14</Age>
</Student>

<Student>
  <Name>Y</Name>
  <Age>16</Age>
  <Address>
    <HNumber>1</HNumber>
    <HName>Something</HName>
    <HPin>33607</HPin>
  </Address>
</Student>

Now I got his displaying on my grid by saying dataProvider=XMLListCollection...

What I want to do is on selection of a row, check if it has "Address" tag, if it has display the other grid, else hide the grid. Any help!!

+1  A: 
if(myDataGrid.selectedItem.hasownproperty("Address")){
  display other grid
}else{
  hide other grid
}
invertedSpear
Another one question here, how would I display only the selected Student's address? because if my structure has an empty Address tag, then the data displayed would be the same? Any suggestions?
Panther24
can you rephrase or provide more detail? Maybe some of your datagrid code?
invertedSpear
A: 

To bind / link two grids You write something like below:

<mx:DataGrid id="grid1" width="100%" dataProvider="{data1}" >
    <mx:columns>
  <mx:DataGridColumn headerText="Name" dataField="@Name"/>
  </mx:columns>
</mx:DataGrid>

<mx:DataGrid id="grid2" width="100%" >
    <mx:columns>
  <mx:DataGridColumn headerText="Name" dataField="@HNumber"/>
  </mx:columns>
</mx:DataGrid>
  <mx:Binding source="grid1.selectedItem.Address" destination="grid2.dataProvider"/>
</mx:Application>

hope this helps. xxx

atsmir01