user2083041
user2083041

Reputation: 513

Deleting dateGrid data?

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

Answers (2)

chethan
chethan

Reputation: 1

         public function deletefromgrid():void {
            if (dg.selectedIndex >= 0) { 
                ac.removeItemAt(dg.selectedIndex); 
        }
        }  

Upvotes: 0

Pete TNT
Pete TNT

Reputation: 8403

private function button1_clickHandler(event:MouseEvent):void{

ac.removeItemAt(myDG.selectedIndex);

}

Upvotes: 1

Related Questions