0

单击网格外的按钮时如何删除数据网格数据。

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

我需要在网格之外有一个按钮。数据来自 dataprovider

4

2 回答 2

1
private function button1_clickHandler(event:MouseEvent):void{

ac.removeItemAt(myDG.selectedIndex);

}
于 2013-06-13T09:01:39.130 回答
0
         public function deletefromgrid():void {
            if (dg.selectedIndex >= 0) { 
                ac.removeItemAt(dg.selectedIndex); 
        }
        }  
于 2014-02-18T10:38:14.703 回答