我使用复选框将数据从一个数据网格发送到另一个数据网格,在将数据更新到另一个数据网格检查行后,在第二个网格中保持相同我想自动取消选中并从第一个网格中删除该行怎么做帮助我? / p>
<mx:DataGrid width="100%" height="40%" id="dg" dataProvider="{dgp}">
<mx:columns>
<mx:DataGridColumn width="150" textAlign="center" dataField="Name" headerText="Name" />
<mx:DataGridColumn width="20" headerText="" >
<mx:itemRenderer>
<fx:Component>
<mx:CheckBox textAlign="center" click="data.selected=!data.selected" selected="{data.selected}"/>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<s:HGroup textAlign="center" >
<s:Image source="C:\Program Files\Adobe\im2.png" click="image1_clickHandler(event)"/>
<s:Image source="C:\Program Files\Adobe\im1.png" click="image1_clickHandler1(event)"/>
</s:HGroup>
<mx:DataGrid width="100%" height="40%" id="dg1" dataProvider="{dgp1}">
<mx:columns>
<mx:DataGridColumn width="150" textAlign="center" dataField="Name" headerText="Name" />
<mx:DataGridColumn width="20" headerText="">
<mx:itemRenderer>
<fx:Component>
<mx:CheckBox textAlign="center" click="data.selected=!data.selected" change="data.selected=false" selected="{data.selected}"/>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:script>
[Bindable]
private var dgp:ArrayCollection = new ArrayCollection([
{Name:"A1",selected:false},
{Name:"A2",selected:false},
{Name:"A3",selected:false},
{Name:"A4",selected:false},
{Name:"A5",selected:false},
{Name:"A6",selected:false}
]);
[Bindable]
private var dgp1:ArrayCollection = new ArrayCollection([
{Name:"B1",selected:false},
{Name:"B2",selected:false},
{Name:"B3",selected:false},
{Name:"B4",selected:false},
{Name:"B5",selected:false},
{Name:"B6",selected:false}
]);
protected function image1_clickHandler(event:MouseEvent):void
{
for (var i:int = 0; i < dgp.length; i++)
{
if (dgp[i].selected == true)
{
dgp.removeItemAt(dg.selectedIndex);
dgp1.addItem(dgp[i]);
dgp1[i].selected=false;
}
}
}
protected function image1_clickHandler1(event:MouseEvent):void
{
for (var i:int = 0; i < dgp1.length; i++)
{
if (dgp1[i].selected == true)
{
dgp1.removeItemAt(dg1.selectedIndex);
dgp.addItem(dgp1[i]);
dgp[i].selected=false;
}
}
}
</mx:script>