티스토리 뷰
<?xml version="1.0" encoding="utf-8"?>
< mx:Application
fontSize="14"
layout="vertical"
creationComplete="initApp()"
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:view="view.*">
<mx:Label text="DataGrid - dataProvider"/>
<mx:DataGrid id="dgDataGrid"
dataProvider="{acArticleData}">
<mx:columns>
<mx:DataGridColumn headerText="번호" dataField="NUM" textAlign="center" width="50"/>
<mx:DataGridColumn headerText="아이디" dataField="ID" textAlign="center" width="200"/>
<mx:DataGridColumn headerText="패스워드" dataField="PASS" textAlign="center" width="200"/>
</mx:columns>
</mx:DataGrid>
<mx:Label text="DataGrid - acArticleData"/>
<mx:DataGrid id="dgDataGrid2"
itemClick="if(dgDataGrid2.selectedItem) itemClickHandler(dgDataGrid2.selectedItem.NUM)">
<mx:columns>
<mx:DataGridColumn headerText="번호" dataField="NUM" textAlign="center" width="50"/>
<mx:DataGridColumn headerText="아이디" dataField="ID" textAlign="center" width="200"/>
<mx:DataGridColumn headerText="패스워드" dataField="PASS" textAlign="center" width="200"/>
</mx:columns>
</mx:DataGrid>
<mx:ViewStack id="mainViewStack" width="100%" height="100%">
<view:boardList id="boardList"/>
</mx:ViewStack>
<mx:ViewStack id="mainViewStack2" width="100%" height="100%">
<view:boardEdit id="boardEdit"/>
</mx:ViewStack>
<!-- Script -->
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.http.HTTPService;
import mx.managers.CursorManager;
import mx.controls.Alert;
[Bindable]
private var acArticleData:ArrayCollection = new ArrayCollection;
private var httpserv:HTTPService;
private function initApp():void {
httpserv = new HTTPService();
httpserv.method = "POST";
httpserv.resultFormat = "e4x";
httpserv.url = "http://dbs.dtitech.kr/Sub/cus/testBoard/php/SqlMapQuery.php";
var sqlArticle:Object = new Object;
sqlArticle.viewCheck = "boardList";
httpserv.addEventListener("result", resultHandler);
httpserv.addEventListener("fault", faultHandler);
httpserv.send(sqlArticle);
CursorManager.setBusyCursor();
}
private function itemClickHandler(article_num:int):void {
}
private function resultHandler(event:ResultEvent):void {
CursorManager.removeBusyCursor();
httpserv.removeEventListener("result", resultHandler);
httpserv.removeEventListener("fault", faultHandler);
var xmlArticleData:XMLList = new XMLList();
xmlArticleData = event.result.articles.article;
acArticleData.removeAll();
var i:int;
for(i=0; i<xmlArticleData.length(); i++) {
var xmlArticle:XML = xmlArticleData[i];
acArticleData.addItem({
NUM : xmlArticle.NUM,
ID : xmlArticle.ID,
PASS : xmlArticle.PASS
});
}
dgDataGrid2.dataProvider = acArticleData;
boardList.dgDataGrid3.dataProvider = acArticleData;
}
private function faultHandler(event:FaultEvent):void {
CursorManager.removeBusyCursor();
httpserv.removeEventListener("result", resultHandler);
httpserv.removeEventListener("fault", faultHandler);
Alert.show(event.toString());
}
]]>
</mx:Script>
< /mx:Application>
'Language > Flex' 카테고리의 다른 글
[ Flex ][ Source ] SQLite 기본 소스 - AIR 전용 (0) | 2015.11.29 |
---|---|
[ Flex ][ Source ] circle 원 그리기 - Flash에서는 정상 Flex에서는 오류가 발생함 (원인 확인불가) - 해결 rawChildren.addChild() (0) | 2015.11.29 |
[ Flex ][ Source ] Alert - 내용수정 필요 (0) | 2015.11.29 |
[ Flex ][ Source ] ex08_04 : 전자랜지 (0) | 2015.11.29 |
[ Flex ][ Source ] ex08_03 : Button Event / MouseWheel 값 event.delta (0) | 2015.11.29 |