开发者

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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜