Vivek
Vivek

Reputation: 1461

Flex + DataGrid + Dynamic Display on Selection

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!!

Upvotes: 0

Views: 611

Answers (2)

atsmir01
atsmir01

Reputation: 1

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

Upvotes: 0

invertedSpear
invertedSpear

Reputation: 11054

if(myDataGrid.selectedItem.hasownproperty("Address")){
  display other grid
}else{
  hide other grid
}

Upvotes: 1

Related Questions