2009-12-17 43 views
0

返回Flex另一个问题。 我有一个XML结构是怎样的?Flex + DataGrid +选择上的动态显示

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

现在,我得到了他说的dataProvider =的XMLListCollection ...

我想要做的是一排,检查的选择,显示在我的网格如果它有“地址”标签,如果它有显示其他网格,否则隐藏网格。 任何帮助!

回答

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

另一个问题在这里,我将如何显示只有选定的学生的地址?因为如果我的结构有一个空的地址标记,那么显示的数据将是相同的?有什么建议么? – Vivek 2009-12-18 04:28:31

+0

你能改说或提供更多细节吗?也许你的一些datagrid代码? – invertedSpear 2009-12-18 15:26:03

0

要绑定/连接两个网格你写类似如下:

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

希望这会有所帮助。 xxx