티스토리 뷰
출처
http://blog.jidolstar.com/17
columninfo.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<msg>ok</msg>
<columninfo>
<column>
<name>aaa</name>
</column>
<column>
<name>bbb</name>
</column>
</columninfo>
</root>
test.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="448"
creationComplete="init()">
<mx:HTTPService id="httpdata" url="http://localhost:8080/examples/columninfo.xml" />
<mx:Script>
<![CDATA[
import mx.collections.*;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
public var httpServ:HTTPService;
[Bindable]
public var xlcData:XMLListCollection;
public function init():void
{
httpServ = new HTTPService();
request("http://localhost:8080/examples/columninfo.xml");
}
public function request(url:String, params:Object=null):void
{
this.httpServ.url = url;
this.httpServ.method = "GET";
this.httpServ.resultFormat="e4x";
this.httpServ.addEventListener("result", resultHandler);
this.httpServ.addEventListener("fault", faultHandler);
this.httpServ.send(params);
}
public function resultHandler(e:ResultEvent):void
{
var xlData:XMLList = new XMLList(e.result);
if(xlData.elements("msg").toString()!="ok") {
mx.controls.Alert.show(xlData.elements("msg").toString(),"Error");
} else {
xlcData = new XMLListCollection(xlData.elements("columninfo"));
}
var columns : Array = grid1.columns;
var tmpCol : DataGridColumn;
// mx.controls.Alert.show(xlcData.toXMLString());
var item:XML;
for each(item in xlcData.children()) {
tmpCol = new DataGridColumn();
tmpCol.headerText = item.children().text();
columns.push(tmpCol);
}
grid1.columns = columns;
}
public function faultHandler(e:FaultEvent):void
{
mx.controls.Alert.show("데이타를 읽는 중 에러\n"+e.fault.faultString);
}
]]>
</mx:Script>
<mx:DataGrid id="grid1" x="54" y="106" width="280" height="139"/>
<mx:Button x="54" y="60" label="Button"/>
</mx:Application>
- Total
- Today
- Yesterday
- koba2010
- 동경
- Spring MVC
- 레이싱모델 익스트림 포토 페스티벌
- Mac
- SAS
- 송주경
- Spring
- NDK
- ble
- JavaScript
- android
- sas2009
- oracle
- 일본여행
- 전예희
- Delphi Tip
- 튜닝쇼 2008
- Linux
- ubuntu
- 서울오토살롱
- KOBA
- MySQL
- flex
- 지스타2007
- Delphi
- BPI-M4
- ffmpeg
- Xcode
- Java
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |