<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var dataArrayC:ArrayCollection = new ArrayCollection();
private function init():void{
this.dataArrayC = new ArrayCollection([{value: "1"},{value: "2"}, {value:"3"}]);
this.rowCountLabel.text = "DataGrid rowCount: "+this.dataGrid.rowCount;
var viewSourceItem:ContextMenuItem = new ContextMenuItem("View Source", true);
var contextMenuCustomItems:Array = application.contextMenu.customItems;
contextMenuCustomItems.push(viewSourceItem);
viewSourceItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, showSource);
}
private function showSource(event:Event):void
{
navigateToURL(new URLRequest("http://blog.arnomanders.nl/upload/"),"_blank");
}
private function addRowToDataGrid():void{
this.dataArrayC.addItem({value:this.dataArrayC.length+ 1});
if (this.rowCountToOneCheckbox.selected){
this.dataGrid.rowCount = 1;
this.dataGrid.rowCount = this.dataArrayC.length;
}
this.rowCountLabel.text = "DataGrid rowCount: "+this.dataGrid.rowCount;
}
]]>
</mx:Script>
<mx:DataGrid id="dataGrid" dataProvider="{this.dataArrayC}" rowCount="{this.dataArrayC.length}"
showHeaders="false" variableRowHeight="true"
width="400">
</mx:DataGrid>
<mx:Button x="400" label="add new row" click="{addRowToDataGrid();}" />
<mx:CheckBox x="400" y="40" id="rowCountToOneCheckbox" selected="false" label="first reset rowCount to 1" />
<mx:Label id="rowCountLabel" x="400" y="20" text=""/>
</mx:Application>