Reputation: 513
How to remove datagrid data when a button is clicked, which is outside the grid.
[Bindable]
private var ac:ArrayCollection=new ArrayCollection([{artist: "John", album:"AAA", price:"100.01", selected: false},
{artist: "Jai", album:"BBB", price:"101.01", selected: false}, {artist: "Jack", album:"CCC", price:"110.01", selected: false}]);
<s:DataGrid id="myDG" width="50%" height="50%" dataProvider="{ac}"
>
<s:columns>
<s:ArrayCollection>
<s:GridColumn dataField="artist" headerText="ARTIST"/>
<s:GridColumn dataField="album" headerText="ALBUM"/>
<s:GridColumn dataField="price" headerText="PRICE" >
<s:itemEditor>
<fx:Component>
<s:ComboBoxGridItemEditor>
<s:dataProvider>
<s:ArrayList>
<fx:String>100</fx:String>
<fx:String>200</fx:String>
<fx:String>300</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:ComboBoxGridItemEditor>
</fx:Component>
</s:itemEditor>
</s:GridColumn>
</s:ArrayCollection>
</s:columns>
</s:DataGrid>
i need to have a button outside the grid.data is from dataprovider
Upvotes: 0
Views: 54
Reputation: 1
public function deletefromgrid():void {
if (dg.selectedIndex >= 0) {
ac.removeItemAt(dg.selectedIndex);
}
}
Upvotes: 0
Reputation: 8403
private function button1_clickHandler(event:MouseEvent):void{
ac.removeItemAt(myDG.selectedIndex);
}
Upvotes: 1