Posted on

使用dataGrid和HTTPService製作表格

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
creationComplete="booksXML.send()" width="800" height="600">
<mx:HTTPService
id="booksXML"
url="data/book_store.xml"/>

<mx:Label color="0xFFFFFF"
text="** {booksXML.lastResult.store.store_title} **" fontSize="18" fontWeight="bold"/>
<mx:DataGrid width="600" height="400"
dataProvider="{booksXML.lastResult.store.book}">
<mx:columns>
<mx:DataGridColumn headerText="編號" dataField="id" width="30"/>
<mx:DataGridColumn headerText="書名" dataField="bookname"/>
<mx:DataGridColumn headerText="分類" dataField="category" width="80"/>
<mx:DataGridColumn headerText="售價" dataField="sprice" width="60"/>
<mx:DataGridColumn headerText="特價" dataField="sale" width="60"/>
</mx:columns>
</mx:DataGrid>
<mx:HBox>
<mx:Label color="0xFFFFFF"
text="書店地址:{booksXML.lastResult.store.store_address}"/>
<mx:Spacer width="200"/>
<mx:Label color="0xFFFFFF"
text="聯絡電話:{booksXML.lastResult.store.store_telephone}"/>
</mx:HBox>
</mx:Application>