如何停止追加到我的数据网格的数据行?我在州之间切换。每次我返回update_dg_form状态时,其他networkInfo行都会添加到datagrid。
private function update_dg(event:MouseEvent):void
{
var ntf:Vector.<NetworkInterface> = NetworkInfo.networkInfo.findInterfaces();
for each (var interfaceObj:NetworkInterface in ntf)
{
networkInfo.addItem({"dg_display_name" : interfaceObj.displayName, "dg_mac_address" : interfaceObj.hardwareAddress});
}
currentState = 'update_dg_form';
}
<mx:DataGrid id="network_adapter" includeIn="update_dg_form" x="55" y="280" width="516" height="111" dataProvider="{networkInfo}" selectedIndex="0">
<mx:columns>
<mx:DataGridColumn dataField="dg_display_name" headerText="Network Adapter"/>
<mx:DataGridColumn dataField="dg_mac_address" headerText="MAC Address"/>
</mx:columns>
</mx:DataGrid>
答案 0 :(得分:0)
您可以在使用networkInfo.removeAll();
private function update_dg(event:MouseEvent):void {
var ntf:Vector.<NetworkInterface> = NetworkInfo.networkInfo.findInterfaces();
networkInfo.removeAll();
for each (var interfaceObj:NetworkInterface in ntf) {
networkInfo.addItem({"dg_display_name":interfaceObj.displayName, "dg_mac_address":interfaceObj.hardwareAddress});
}
currentState = 'update_dg_form';
}
<mx:DataGrid id="network_adapter" includeIn="update_dg_form" x="55" y="280" width="516" height="111" dataProvider="{networkInfo}" selectedIndex="0">
<mx:columns>
<mx:DataGridColumn dataField="dg_display_name" headerText="Network Adapter"/>
<mx:DataGridColumn dataField="dg_mac_address" headerText="MAC Address"/>
</mx:columns>
</mx:DataGrid>