首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

DataGrid删除数据后怎么自动更新

2012-10-09 
DataGrid删除数据后如何自动更新mainl.mxml?xml version1.0 encodingutf-8?mx:Application xmlns

DataGrid删除数据后如何自动更新
mainl.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();">
        <mx:Script>
                <![CDATA[
                        import mx.rpc.events.ResultEvent;
                        import mx.controls.Alert;
                        [Bindable]
                        private function init():void{
                                flash.system.System.useCodePage=true;
                                getBeauty();
                        }
                        private function getBeauty():void{
                                hsGetBeauty.send();
                        }
                        public function delBeauty():void{
                                var delId:Object = new Object;
                                delId.id = dgBeauty.selectedItem.id;
                                hsDelBeauty.send(delId);
                        }
                        private function delResult(event:ResultEvent):void{
                                Alert.show( "Result "+String(event.result) );
                                getBeauty();
                        }
                ]]>
        </mx:Script>
        <mx:Style source="beauty.css"/>
        <mx:HTTPService id="hsGetBeauty" url="http://localhost/beauty/php/getbeauty.php"/>
        <mx:HTTPService id="hsDelBeauty" url="http://localhost/beauty/php/delbeauty.php" method="GET" result="delResult(event)"/>
        <mxataGrid styleName="dgBeauty" id="dgBeauty" x="48" y="29" width="646" height="207" dataProvider="{hsGetBeauty.lastResult.beauties.beauty}">
                <mx:columns>
                        <mxataGridColumn headerText="ID" dataField="id"/>
                        <mxataGridColumn headerText="姓名" dataField="name"/>
                        <mx:DataGridColumn headerText="年龄" dataField="age"/>
                        <mx:DataGridColumn headerText="婚否" dataField="marry"/>
                        <mx:DataGridColumn headerText="出生日期" dataField="birth"/>
                        <mx:DataGridColumn headerText="删除" width="60">
                                <mx:itemRenderer>
                                        <mx:Component>
                                                <mx:Button label="删除" click="outerDocument.delBeauty()"/>
                                        </mx:Component>
                                </mx:itemRenderer>
                        </mx:DataGridColumn>
                </mx:columns>
        </mx:DataGrid>
</mx:Application>

热点排行