Skip to content

Instantly share code, notes, and snippets.

@junwatu
Created August 18, 2011 03:38
Show Gist options
  • Save junwatu/1153244 to your computer and use it in GitHub Desktop.
Save junwatu/1153244 to your computer and use it in GitHub Desktop.
BookDetails component
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"
creationComplete="initdg()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.ListEvent;
import com.developmentarc.core.utils.EventBroker;
[Bindable]
public var dataTwo:Array = [{ISBN: "978-0-470-22904-0",
Publisher : "Wiley Publishing Inc.", Author:"Rich Tretola"}];
[Bindable]
public var dataThree:Array = [{ISBN: "978-0-596-52694-8 ",
Publisher : "O'Reilly Media, Inc", Author:"Colin Moock"}];
private function initdg():void {
//init
subscribeToListChange();
}
/**
* Catatan : ListEvent sebagai argumen fungsi EventBroker.subscribe()
*/
public function subscribeToListChange():void {
EventBroker.subscribe(ListEvent.ITEM_CLICK,handleListChange);
}
public function handleListChange(e:ListEvent):void {
if(e.rowIndex == 0){
detailBuku.dataProvider = dataTwo;
}else if(e.rowIndex == 1){
detailBuku.dataProvider = dataThree;
}else {
//nothing todo
};
}
]]>
</mx:Script>
<mx:DataGrid id="detailBuku" width="100%" height="100%" dataProvider="{dataTwo}">
<mx:columns>
<mx:DataGridColumn dataField="Author" headerText="Author"/>
<mx:DataGridColumn dataField="ISBN" headerText="ISBN"/>
<mx:DataGridColumn dataField="Publisher" headerText="Publisher"/>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment